RAS 19.1 script changes from the 18.1 script
Produced: 4/7/2023 4:42:02 PM
   
Mode:  Differences  
Left file: C:\gitstuff\Parallels-RAS-V19.x-Doc-Script-3.01\RAS_Inventory_V3_0.ps1  
Right file: C:\gitstuff\Parallels-RAS-V19.x-Doc-Script-3.01\RAS_Inventory_V2.5.ps1  
        Creates a complete inventory of a V19.x or later Parallels Remote Application Server. <>         Creates a complete inventory of a V18.1 or later Parallels Remote Application Server.
 
        Creates a complete inventory of a V19.x or later Parallels Remote Application Server  <>         Creates a complete inventory of a V18.1 or later Parallels Remote Application Server 
 
        Word and PDF documents include a Cover Page, Table of Contents, and Footer. <>         Word and PDF document includes a Cover Page, Table of Contents, and Footer.
 
        June 1, 2023 at 6PM is 2023-06-01_1800. <>         June 1, 2021 at 6PM is 2021-06-01_1800.
 
        Output filename will be ReportName_2023-06-01_1800.<ext>. <>         Output filename will be ReportName_2021-06-01_1800.<ext>.
 
        PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 <>         PS C:\PSScript > .\RAS_Inventory_V2.5.ps1
 
        PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -RASSite EMEASite <>         PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -RASSite EMEASite
 
        PS C:\PSScript .\RAS_Inventory_V3.0.ps1 -MSWord -CompanyName "Carl Webster  <>         PS C:\PSScript .\RAS_Inventory_V2.5.ps1 -MSWord -CompanyName "Carl Webster 
 
        PS C:\PSScript .\RAS_Inventory_V3.0.ps1 -PDF -CN "Carl Webster Consulting" -CP  <>         PS C:\PSScript .\RAS_Inventory_V2.5.ps1 -PDF -CN "Carl Webster Consulting" -CP 
 
        PS C:\PSScript .\RAS_Inventory_V3.0.ps1 -CompanyName "Sherlock Holmes  <>         PS C:\PSScript .\RAS_Inventory_V2.5.ps1 -CompanyName "Sherlock Holmes 
 
        PS C:\PSScript .\RAS_Inventory_V3.0.ps1 -CompanyName "Sherlock Holmes  <>         PS C:\PSScript .\RAS_Inventory_V2.5.ps1 -CompanyName "Sherlock Holmes 
 
        PS C:\PSScript >.\RAS_Inventory_V3.0.ps1 -Dev -ScriptInfo -Log <>         PS C:\PSScript >.\RAS_Inventory_V2.5.ps1 -Dev -ScriptInfo -Log
 
        PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer mail.domain.tld -From  <>         PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer mail.domain.tld -From 
 
        PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer mailrelay.domain.tld -From  <>         PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer mailrelay.domain.tld -From 
 
        PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer  <>         PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer 
 
        PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer smtp.office365.com -SmtpPort 587 <>         PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer smtp.office365.com -SmtpPort 587
 
        PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer smtp.gmail.com -SmtpPort 587 <>         PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer smtp.gmail.com -SmtpPort 587
 
        NAME: RAS_Inventory_V3.0.ps1 <>         NAME: RAS_Inventory_V2.5.ps1
        VERSION: 3.01           VERSION: 2.53
 
        LASTEDIT: April 7, 2023 <>         LASTEDIT: February 13, 2022
 
#Work on 3.0 started on 15-Nov-2022 <>  
    #
#Version 3.01   #Version 2.53 13-Feb-2022
    #       When processing RD Session Hosts, the script had bad logic that assumed there was always only one RDS Group.
    #               This caused some Agent settings to show as System.Object[] instead of their Numeric or Boolean value
    #               For example:
    #                       Agent settings
    #                               Port                                                  : System.Object[]
    #                               Max Sessions                                          : System.Object[]
    #                               Support Windows Shell URL namespace objects           : System.Object[]
    #                               Allow 2xRemoteExec to send command to the client      : System.Object[]
    #                               Use RemoteApp if available                            : System.Object[]
    #                               Enable applications monitoring                        : System.Object[]
    #                               Allow file transfer command (HTML5 and Chrome clients): System.Object[]
    #                               Do not allow to change location                       : System.Object[]
    #                               Enable drive redirection cache                        : System.Object[]
    #               Oops, my bad. The fix only took one line of code and changing two variables.
    #               Now the results are correct.
    #                       Agent settings
    #                               Port                                                  : 3389
    #                               Max Sessions                                          : 25
    #                               Support Windows Shell URL namespace objects           : True
    #                               Allow 2xRemoteExec to send command to the client      : True
    #                               Use RemoteApp if available                            : False
    #                               Enable applications monitoring                        : True
    #                               Allow file transfer command (HTML5 and Chrome clients): True
    #                               Do not allow to change location                       : False
    #                               Enable drive redirection cache                        : True
    #               Thanks to Thomas Krampe for all his help and remote sessions to track this down
    #
    #Version 2.52 7-Feb-2022
    #       Added Function GetRASStatus to return the full status text for several RAS Status cmdlets
    #               Updated all AgentState outputs to use the value from GetRASStatus
    #       Added HALB output
    #               Virtual Servers
    #                       Properties
    #                       General
    #                       LB gateway payload
    #                       LB SSL payload
    #                       Devices
    #                       Advanced
    #       Changed the date format for the transcript and error log files from yyyy-MM-dd_HHmm format to the FileDateTime format
    #               The format is yyyyMMddTHHmmssffff (case-sensitive, using a 4-digit year, 2-digit month, 2-digit day, 
    #               the letter T as a time separator, 2-digit hour, 2-digit minute, 2-digit second, and 4-digit millisecond). 
    #               For example: 20221225T0840107271.
    #       Fixed call to Get-RASThemeFooterURL to always return an array (Thanks to Thomas Krampe for the debugging time)
    #       Fixed missing RDS Group Default settings (Thanks to Thomas Krampe)
    #       Fixed several logic errors where I assumed there were always RDS groups
    #       Fixed the German Table of Contents (Thanks to Rene Bigler)
    #               From 
    #                       'de-'   { 'Automatische Tabelle 2'; Break }
    #               To
    #                       'de-'   { 'Automatisches Verzeichnis 2'; Break }
    #       For Policy setting Session/Connection/Primary connection/Login/Auto Login, change property name AutoStart to AutoLogin
#       In Function OutputPublishingSettings, add AVDApp and AVDDesktop to WVDApp and WVDDesktop   #       In Function AbortScript, add test for the winword process and terminate it if it is running
    #               Added stopping the transcript log if the log was enabled and started
#       In Function OutputRASMailboxSettings, added the missing enum fixed in 19.2   #       In Function OutputFarmSite, only get the first Publishing Agent server for the Farm/Site settings
#               YesTLS12IfAvailable     - Use TLS 1.2 if available    
#       In Function OutputSite, add code to handle the different types of Registry Optimizations   #       In Functions AbortScript and SaveandCloseDocumentandShutdownWord, add code from Guy Leech to test for the "Id" property before using it
#               REG_DWORD   #       Replaced most script Exit calls with AbortScript to stop the transcript log if the log was enabled and started
#               REG_EXPAND_SZ   #       Updated the help text
#               REG_MULTI_SZ   #       Updated the ReadMe file
#               REG_QWORD   #       Updated to allow running the script for RAS versions greater than 18.1
#               REG_SZ    
 
#Version 3.00 25-Mar-2023 <> #Version 2.51 11-Sep-2021
    #       Added array error checking for non-empty arrays before attempting to create the Word table for most Word tables
    #       Added Function OutputReportFooter
    #       Added Parameter ReportFooter
    #               Outputs a footer section at the end of the report.
    #               Report Footer
    #                       Report information:
    #                               Created with: <Script Name> - Release Date: <Script Release Date>
    #                               Script version: <Script Version>
    #                               Started on <Date Time in Local Format>
    #                               Elapsed time: nn days, nn hours, nn minutes, nn.nn seconds
    #                               Ran from domain <Domain Name> by user <Username>
    #                               Ran from the folder <Folder Name>
    #       Updated Functions SaveandCloseTextDocument and SaveandCloseHTMLDocument to add a "Report Complete" line
    #       Updated Functions ShowScriptOptions and ProcessScriptEnd to add $ReportFooter
    #       Updated the help text
    #       Updated the ReadMe file
 
  <> #Version 2.50 12-Aug-2021
    #       Added a version test so the script only works with RAS 18.1
    #       Added documenting (my best attempt) an Azure provider connection
    #       Added Certificates
    #               Alternate Names
    #               General
    #                       Alternate Names
    #       Added Policies summary
    #       Added Policy Properties (took five days for this one section)
    #               Policy
    #               Policy/Criteria
    #               Session
    #               Session/Connection
    #               Session/Connection/Primary connection
    #               Session/Connection/Secondary connections
    #               Session/Connection/Reconnection
#       Added Connection Brokers/Auto-promotion   #               Session/Connection/Computer name
    #               Session/Connection/Advanced settings
    #               Session/Connection/Web authentication
    #               Session/Connection/Multifactor authentication
    #               Session/Connection/Session prelaunch
    #               Session/Connection/Local proxy address
    #               Session/Display
    #               Session/Display/Settings
    #               Session/Display/Multi-monitor
    #               Session/Display/Published applications
    #               Session/Display/Desktop options
    #               Session/Display/Browser
    #               Session/Printing
    #               Session/Scanning
    #               Session/Audio
    #               Session/Keyboard
    #               Session/Local devices and resources
    #               Session/Local devices and resources/Clipboard
    #               Session/Local devices and resources/Disk drives
    #               Session/Local devices and resources/Devices
    #               Session/Local devices and resources/Video capture devices (not in PowerShell yet)
    #               Session/Local devices and resources/Ports
    #               Session/Local devices and resources/Smart cards
    #               Session/Local devices and resources/Windows touch input
#       Added to Secure Gateway/Network "Only allow Let's Encrypt verification"   #               Session/Local devices and resources/File transfer
    #               Session/Experience
    #               Session/Experience/Performance
    #               Session/Experience/Compression
    #               Session/Network
    #               Session/Server authentication
    #               Session/Advanced settings
    #               Client options
    #               Client options/Connection
    #               Client options/Logging
    #               Client options/Update
    #               Client options/PC keyboard
    #               Client options/Single Sign-On
    #               Client options/Advanced
    #               Client options/Advanced/Global
    #               Client options/Advanced/Language
#       Added Video Capture Devices policy settings   #               Client options/Advanced/Printing
    #               Client options/Advanced/Windows client
    #               Client options/Advanced/RemoteFX USB redirection
    #               Control settings
    #               Control settings/Connections
    #               Control settings/Password
    #               Control settings/Import and export
    #               Redirection
    #       Added Reporting
    #               RAS reporting configuration
    #                       Session information
    #                       Server counters information
    #                       Custom reports
    #               RAS Performance Monitor configuration
    #       Added Themes
    #               General
    #               Messages
    #               HTML5 client/Branding
    #               HTML5 client/Language bar
    #               HTML5 client/Messages
    #               HTML5 client/Gateway
    #               HTML5 client/Legal policies
    #               Windows client/Branding
    #               Windows client/Messages
    #               Windows client/Custom menu
    #       Added to Connection/Multi-factor authentication:
    #               Enable MFA for all users except
    #               Disable MFA for all users except
    #               User or group list
    #               Updated all items and text to match the console (a lot of work)
    #               Added for Azure RADIUS, Duo RADIUS, FortiAuthenticator RADIUS, TekRADIUS, and RADIUS
    #                       Connection
    #                       Attributes
    #                       Automation
    #               Added DeepNet Provider
    #                       Connection
    #                       Application
    #                       Authentication
    #               Added SafeNet Provider
    #                       Connection
    #                       Authentication
    #               Added Google Authenticator
    #                       General
    #       Added to Gateway and Gateway Default Settings:
    #               HTML5/Allow cross-origin resource sharing
    #                       Domains for cross-origin resource sharing
    #                       Browser cache time in months
    #               HTML5/Clipboard redirection
    #               HTML5/File Transfer Direction
    #               HTML5/Use ciphers according to server preference
    #               Wyse/Do not warn if server certificate is not verified
    #       Added to Provider/Agent settings Drag and drop
    #       Added to Published Items their Status
    #               Disabled
    #               Enabled
    #               In maintenance
    #       Added to RD Session Host, RD Session Host Groups, Provider and Default Site Settings:
    #               Agent settings/File Transfer Direction
    #               Agent settings/File Transfer Location
    #               Agent settings/File Transfer Do not allow to change location
    #       Change the wording in Connection/Authentication and Multi-factor authentication to match the console
    #       Fixed a lot of HTML and text formatting issues
    #       In Certificates/General, moved Expiration date to before Common name
    #       In Published Resources, only show Associated File Extensions if the EnableFileExtensions property is True
#       Changed "Keep existing VRRP/keepalive settings" to "Keep existing VRRP/keepalived settings" for HALB Properties/Advanced   #               If you add file extensions and later disable file extensions, the extensions previously entered are still there
    #       Renamed in Gateway/SSL/TLS/HSTS settings "Max-age" to "Browse cache time in months"
    #       Renamed in RDS Host/Agent, RDS Group/Agent, and Provider/Agent settings:
    #               "Support Shell URL namespace objects" to "Support Windows Shell URL namespace objects"
#       Comment out FSLogix replicate settings as I don't see them in the console now   #       Removed the Restrictions label from Gateways/HTML5 as it is no longer in the console
    #       Updated Function GetVDIType with Hypervisor data for ESXi 7.0 and vCenter 7.0
    #       Updated the Help text
    #       Updated the ReadMe file
    #
    #Version 2.10 25-Apr-2021
#       Removed policy properties that no longer exist   #       Fixed wrong variables used to determine User Profile technology
    #       For RD Session Hosts properties:
    #               Renamed the Properties tab to General
    #               Renamed Agent Settings to Agent settings
    #               Renamed User Profile to User profile
    #               Renamed Desktop Access to Desktop access
    #               Renamed RDP Printer to RDP printer
    #       For RD Session Hosts Groups properties:
    #               Renamed Agent Settings to Agent settings
    #               Renamed Desktop Access to Desktop access
    #               Renamed RDP Printer to RDP printer
    #       For RD Session Hosts Schedule properties:
    #               Renamed the Properties tab to General
    #       For VDI Providers properties:
    #               Renamed Agent Settings to Agent settings
    #               Renamed RDP Printer to RDP printer
    #       For Gateways properties:
    #               Renamed the Properties tab to General
    #       For Certificates properties:
    #               Renamed the Properties tab to General
    #       For Administration, Settings:
    #               Rename Customer Experience Program to Customer experience program
    #               Rename HTTP Proxy settings to HTTP proxy settings
    #       For License:
    #               Rename License Details to License details
    #       For VDI, the following changes were made:
    #               Providers tab, added Direct address
    #               Providers properties, renamed the Properties tab to General
    #               Providers properties, Agent settings:
    #                       Removed "Publishing Session Timeout"
    #                       Added "Enable drive redirection cache"
    #               Pools tab:
    #                       Pools:
    #                               Added Last modification by
    #                               Added Modified on
    #                               Added Created by
    #                               Added Created on
    #               Templates tab:
    #                       For template properties, removed Status as I was getting the wrong status property
    #                       Template properties, renamed the Properties tab to General
    #                       Advanced tab, renamed Native Pool to Resource pool
    #       Updated the ReadMe file
#          #
    #Version 2.00 20-Apr-2021
    #       Added 59 RDS Agent States
    #       Added a message to the error message for the missing RAS module
    #               Added a link to the V2 ReadMe file
    #       Added a parameter, RASSite, allowing the report to contain data for the specified Site
    #       Added additional Notification handlers types
    #       Added FSLogix to Farm/Site/Settings/Features
    #       Added Function GetFarmSites
    #       Added the missing License section for published RDSH applications to Text and HTML output
    #       Added to Universal Printing/Printer drivers, "Settings are replicated to all Sites"
    #       Added UPD and FSLogix to the User Profile tab for both RD Session Hosts and RD Session Hosts/Groups
    #       Added VDI Pool Member type of "ALLGUESTSONPROVIDER"
    #       Added WVD Apps and Desktops to Publishing
    #       Changed $DesktopSize to use the new values of the DesktopSize property
    #               Removed the property UseAvailableArea as it no longer exists
    #       Changed all RAS cmdlet names to use the new naming scheme Get-RAS*
    #       Changed all Write-Verbose statements from Get-Date to Get-Date -Format G as requested by Guy Leech
    #       Changed Get-RASVDIHost to the new Get-RASProvider
    #       Changed Get-RASVDIHostStatus to the new Get-RASProviderStatus
    #       Changed PoSH module from PSAdmin to RASAdmin
    #       Changed some Write-Warnings to Write-Host as they are not warnings
    #               Reformat most of the Write-Host statements to make the console output look better
#       There are over 1500 differences between the last 2.5 script update and this new 3.00.   #       Changed the font size of Word/PDF tables from 11 to 10 to prevent most word wrapping to multiple lines
#               The HTML diff file is over 25MB in size.   #       Changed the RDS User Profile Technology to one line instead of two
    #       Changed the variable $MasterPublishingAgent to $PrimaryPublishingAgent
    #               Changed the matching column headings from Master Publishing Agent to Primary Publishing Agent
    #       Changed TWAIN and WIA state from "Unable to retrieve ___ Scanning information" to $False if unable to retrieve data or retrieved no data
    #       Fixed several alignment issues in the text output
    #       Fixed several formatting issues with the HTML and Word/PDF output
    #       Fixed several invalid $Null comparisons
    #       For RD Session Hosts, Agent settings, add the option Enable drive redirection cache
    #       For replicating settings, standardized on the wording "Settings are replicated to all Sites" followed by True or False
    #       In the Administration section, add the following:
    #               Accounts, Receive system notifications
    #               Settings, Miscellaneous, Reset idle RAS Console session after
    #       In the Connection section, add the following:
    #               Allowed devices, headings for Secure Access and Device Access
#               If you really want to see all the changes between 2.5 and 3.0, look at the diff file in GitHub.   #               Allowed devices, Allow only clients with the latest security patches
    #               Allowed devices, Device Access, Mode text label
    #       In the Filters section, reformatted the output to make it more readable (at least to me)
    #       In the Load Balancing section added CPU Optimization
    #       Moved Notification from Administration to Site Settings
    #       Removed all Turbo.net content
    #       Removed Function ProcessSites
    #       Removed MaxGuests from Provider/Agent Settings
    #       Removed property EnableCPULB from Load Balancing section
    #       Removed UPD settings from RD Session Hosts properties and Groups properties
    #       Reorder Parameters in an order recommended by Guy Leech
    #       Reworked how the script processed a Farm with multiple Sites
    #               For most of the Get-RAS* cmdlets, where needed, added the -Site parameter
    #       Updated Function SetWordCellFormat to the latest version
    #       Updated the Allowed authentication types to the new text in the console and handled multiple selections
    #       Updated the help text
    #       Updated the ReadMe file
    #       When retrieving data for Gateways, set variables to values specifying if the Gateway data could not be retrieved or found no Gateway data
    #       When using the output from Get-RASVDITemplate, change VDIHostId to ProviderId
    #       With the addition of the "Last modification by", "Modified on", "Created by", and "Created on" 
    #               properties to the PowerShell cmdlets, add those four properties to the relevant report sections
 
$SaveEAPreference         = $ErrorActionPreference +-  
$ErrorActionPreference    = 'SilentlyContinue'    
$Error.Clear()    
     
 
$script:MyVersion         = '3.01' <> $script:MyVersion         = '2.53'
$Script:ScriptName        = "RAS_Inventory_V3.0.ps1"   $Script:ScriptName        = "RAS_Inventory_V2.5.ps1"
$tmpdate                  = [datetime] "04/07/2023"   $tmpdate                  = [datetime] "02/13/2022"
 
        #[int]$wdColorBlack            = 0 <>         [int]$wdColorBlack            = 0
        #[int]$wdColorGray05           = 15987699            [int]$wdColorGray05           = 15987699 
 
        #[int]$wdColorRed              = 255 <>         [int]$wdColorRed              = 255
 
        #[int]$wdColorYellow           = 65535 <>         [int]$wdColorYellow           = 65535
 
        #[int]$wdAlignParagraphLeft = 0 <>         [int]$wdAlignParagraphLeft = 0
        #[int]$wdAlignParagraphCenter = 1           [int]$wdAlignParagraphCenter = 1
        #[int]$wdAlignParagraphRight = 2           [int]$wdAlignParagraphRight = 2
 
        #[int]$wdCellAlignVerticalTop = 0 <>         [int]$wdCellAlignVerticalTop = 0
        #[int]$wdCellAlignVerticalCenter = 1           [int]$wdCellAlignVerticalCenter = 1
        #[int]$wdCellAlignVerticalBottom = 2           [int]$wdCellAlignVerticalBottom = 2
 
        #[int]$wdAutoFitWindow = 2 <>         [int]$wdAutoFitWindow = 2
 
        #[int]$wdAdjustNone = 0 <>         [int]$wdAdjustNone = 0
 
        #[int]$wdAdjustFirstColumn = 2 <>         [int]$wdAdjustFirstColumn = 2
        #[int]$wdAdjustSameWidth = 3           [int]$wdAdjustSameWidth = 3
 
        #[int]$Indent1TabStops = 1 * $PointsPerTabStop <>         [int]$Indent1TabStops = 1 * $PointsPerTabStop
        #[int]$Indent2TabStops = 2 * $PointsPerTabStop           [int]$Indent2TabStops = 2 * $PointsPerTabStop
        #[int]$Indent3TabStops = 3 * $PointsPerTabStop           [int]$Indent3TabStops = 3 * $PointsPerTabStop
        #[int]$Indent4TabStops = 4 * $PointsPerTabStop           [int]$Indent4TabStops = 4 * $PointsPerTabStop
 
        [int]$wdStyleHeading5 = -6 +-  
 
        #[int]$wdTableLightListAccent3 = -206 <>         [int]$wdTableLightListAccent3 = -206
 
        $Script:myHash.Word_Heading5        = $wdStyleheading5 +-  
 
                5 {$Script:Selection.Style = $Script:MyHash.Word_Heading5; Break} +-  
 
  -+         Write-Verbose "$(Get-Date -Format G): RAS Version          : $($Script:RASVersion)"
 
                $Script:RASFullVersion = $Results +-  
 
                If([version]$Script:RASVersion -ge [version]"19.1") <>                 If([version]$Script:RASVersion -ge [version]"18.1")
 
        This script is designed for RAS 19.1 and should not be run on $Results. <>         This script is designed for RAS 18.1 and should not be run on $Results.
 
        If you are running RAS 18.x, please use:  <>         If you are running RAS 18.0, please use: 
 
                $Script:RASFullVersion = "Unable to determine" +-  
 
        This script is designed for RAS 19.1 and your RAS version could not be determined. <>         This script is designed for RAS 18.1 and your RAS version could not be determined.
 
        If you are running RAS 18.x, please use:  <>         If you are running RAS 18.0, please use: 
 
  -+                 Out-File -FilePath $SIFile -Append -InputObject "RAS Version          : $Script:RASVersion" 4>$Null
 
        $Results = Get-RASFarmSettings -EA 0 4>$Null <>         $Results = Get-RASFarmSettings -EA 0
 
  -+                 
                    OutputFarm
 
        Write-Verbose "$(Get-Date -Format G): Output Farm" <>         Write-Verbose "$(Get-Date -Format G): `tOutput Farm"
 
        #Write-Verbose "$(Get-Date -Format G): `tRetrieving Farm Sites" <>         Write-Verbose "$(Get-Date -Format G): `tRetrieving Farm Sites"
 
        Write-Verbose "$(Get-Date -Format G): `tOutput Farm Site $($Site.Name)" <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput Farm Site $($Site.Name)"
 
                Write-Host " <>                 Write-Warning "
                    `n
        No Site Status retrieved for Site $Site.Name.`                   No Site Status retrieved for Site $Site.Name.`
                " -ForegroundColor White                   `n
                    "
 
                $Results = Get-RASBroker -SiteId $Site.Id -EA 0 4> $Null | Select-Object -First 1 #changed in 2.52 to only get the first PA <>                 $Results = Get-RASPA -SiteId $Site.Id -EA 0 4> $Null | Select -First 1 #changed in 2.52 to only get the first PA
 
                $ScriptInformation.Add(@{Data = "Primary Connection Broker"; Value = $PrimaryPublishingAgent; }) > $Null <>                 $ScriptInformation.Add(@{Data = "Primary Publishing Agent"; Value = $PrimaryPublishingAgent; }) > $Null
 
                Line 1 "Site`t`t`t : " $Site.Name <>                 Line 1 "Site`t`t`t: " $Site.Name
                Line 1 "Primary Connection Broker: " $PrimaryPublishingAgent                   Line 1 "Primary Publishing Agent: " $PrimaryPublishingAgent
                Line 1 "Type`t`t`t : " $Type                   Line 1 "Type`t`t`t: " $Type
                Line 1 "State`t`t`t : " $State                   Line 1 "State`t`t`t: " $State
                Line 1 "Description`t`t : " $Description                   Line 1 "Description`t`t: " $Description
                Line 1 "ID`t`t`t : " $ID                   Line 1 "ID`t`t`t: " $ID
                Line 1 "Last modification by`t : " $Site.AdminLastMod                   Line 1 "Last modification by`t: " $Site.AdminLastMod
                Line 1 "Modified on`t`t : " $Site.TimeLastMod.ToString()                   Line 1 "Modified on`t`t: " $Site.TimeLastMod.ToString()
                Line 1 "Created by`t`t : " $Site.AdminCreate                   Line 1 "Created by`t`t: " $Site.AdminCreate
                Line 1 "Created on`t`t : " $Site.TimeCreate.ToString()                   Line 1 "Created on`t`t: " $Site.TimeCreate.ToString()
 
                $rowdata += @(,("Primary Connection Broker",($Script:htmlsb),$PrimaryPublishingAgent,$htmlwhite)) <>                 $rowdata += @(,("Primary Publishing Agent",($Script:htmlsb),$PrimaryPublishingAgent,$htmlwhite))
 
                "HyperVWin2022Std"                                      {$VDIType = "HyperV on Windows Server 2022 Standard Edition"; Break} +-  
                "HyperVWin2022Dtc"                                      {$VDIType = "HyperV on Windows Server 2022 Datacenter Edition"; Break}    
 
                "HyperVFailoverClusterWin2022"          {$VDIType = "HyperV Failover Cluster on Windows Server 2022"; Break} +-  
 
                15                                                                      {$VDIType = "Vmware VCenter Server 7.0"; Break} +-  
 
                "Nutanix5_5"                                            {$VDIType = "Nutanix 5.5"; Break} <>  
                "Nutanix5_10"                                           {$VDIType = "Nutanix 5.10"; Break}    
                "Nutanix5_15"                                           {$VDIType = "Nutanix 5.15"; Break}    
                "Nutanix5_20"                                           {$VDIType = "Nutanix 5.20"; Break}    
                "Nutanix6_5"                                            {$VDIType = "Nutanix 6.5"; Break}    
                "RemotePCStaticUnknown"                         {$VDIType = "Remote PC static unknown"; Break}                   "RemotePCUnknown"                                       {$VDIType = "Remote PC Unknown"; Break}
 
                "RemotePCDynamicUnknown"                        {$VDIType = "Remote PC dynamic unknown"; Break} +-  
 
                "Scale"                                                         {$VDIType = "Scale unknown"; Break} +-  
 
                "Scale8_6_5"                                            {$VDIType = "Scale 8.6.5"; Break} <>  
                "Scale8_8"                                                      {$VDIType = "Scale 8.8"; Break}    
                "Scale8_9"                                                      {$VDIType = "Scale 8.9"; Break}    
                "Scale9_1"                                                      {$VDIType = "Scale 9.1"; Break}    
                "Azure"                                                         {$VDIType = "Azure"; Break}                   "Azure"                                                         {$VDIType = "Azure"; Break}                                     
                21                                                                      {$VDIType = "Azure"; Break}    
                "AzureUnknown"                                          {$VDIType = "Azure"; Break}                                         
                "AVD"                                                           {$VDIType = "AVD"; Break}                                           
                "AWSEC2"                                                        {$VDIType = "AWSEC2"; Break}                                        
 
                #""                                             {$FullRASStatus = ""; Break} +-  
                "AddingMembers"                                 {$FullRASStatus = "Guest being added to the group"; Break}    
 
                "DeleteInProgress"                              {$FullRASStatus = "A delete is currently in progress"; Break} +-  
 
                "FailedPerfCounters"                    {$FullRASStatus = "Performance counters failed to initialize"; Break} +-  
 
                "JoiningToGroup"                                {$FullRASStatus = "A host is current being joined to a group or hostpool"; Break} +-  
 
                "NoAvailableGateways"                   {$FullRASStatus = "There are no RAS Secure Gateways that the Tenant Broker can use to process connections"; Break} +-  
 
                "PendingRecreation"                             {$FullRASStatus = "Machine will be recreated on the last user logoff"; Break} +-  
 
                "RemovingMembers"                               {$FullRASStatus = "Guest being removed from the group"; Break} +-  
                "ScalingIn"                                             {$FullRASStatus = "Deprecated: use RemovingMembers instead"; Break}    
                "ScalingOut"                                    {$FullRASStatus = "Deprecated: use AddingMembers instead"; Break}    
 
        Write-Verbose "$(Get-Date -Format G): Output Site $($Site.Name)" <>         Write-Verbose "$(Get-Date -Format G): `tOutput Site $($Site.Name)"
 
        No RD Session Hosts retrieved for Site $($Site.Name). <>                 No RD Session Hosts retrieved for Site $($Site.Name).
 
                Write-Verbose "$(Get-Date -Format G): `tOutput RD Session Hosts" <>                 Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Hosts"
 
                                Unable to retrieve RDS Status for RDS Host $($RDSHost.Server)` <>                                 Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)`
 
                                        WriteWordLine 0 0 "Unable to retrieve RDS Status for RDS Host $($RDSHost.Server)" <>                                         WriteWordLine 0 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)"
 
                                        Line 0 "Unable to retrieve RDS Status for RDS Host $($RDSHost.Server)" <>                                         Line 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)"
 
                                        WriteHTMLLine 0 0 "Unable to retrieve RDS Status for RDS Host $($RDSHost.Server)" <>                                         WriteHTMLLine 0 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)"
 
                                No RDS Status retrieved for RDS Host $($RDSHost.Server)` <>                                 No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)`
 
                                        WriteWordLine 0 0 "No RDS Status retrieved for RDS Host $($RDSHost.Server)" <>                                         WriteWordLine 0 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)"
 
                                        Line 0 "No RDS Status retrieved for RDS Host $($RDSHost.Server)" <>                                         Line 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)"
 
                                        WriteHTMLLine 0 0 "No RDS Status retrieved for RDS Host $($RDSHost.Server)" <>                                         WriteHTMLLine 0 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)"
 
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $RDSHost.Server; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Address"; Value = $RDSHost.Server; }) > $Null
 
                                        $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $RDSStatus.PreferredBroker; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Preferred PA"; Value = $RDSStatus.PreferredPA; }) > $Null
 
  +-  
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 300;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Name`t`t`t`t: " $RDSHost.Server    
                                        Line 2 "Status`t`t`t`t: " $RDSStatusAgentState    
                                        Line 2 "CPU`t`t`t`t: " "$($RDSStatus.CPULoad)%"    
                                        Line 2 "RAM`t`t`t`t: " "$($RDSStatus.MemLoad)%"    
                                        Line 2 "Disk read time`t`t`t: " "$($RDSStatus.DiskRead)%"    
                                        Line 2 "Disk write time`t`t`t: " "$($RDSStatus.DiskWrite)%"    
                                        Line 2 "Sessions`t`t`t: " $Sessions    
                                        Line 2 "Preferred Connection Broker`t: " $RDSStatus.PreferredBroker    
                                        Line 2 "Operating system`t`t: " $RDSStatus.ServerOS    
                                        Line 2 "Agent version`t`t`t: " $RDSStatus.AgentVer    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Name",($Script:htmlsb),$RDSHost.Server,$htmlwhite)    
                                        $rowdata += @(,("Status",($Script:htmlsb),$RDSStatusAgentState,$htmlwhite))    
                                        $rowdata += @(,("CPU",($Script:htmlsb),"$($RDSStatus.CPULoad)%",$htmlwhite))    
                                        $rowdata += @(,("RAM",($Script:htmlsb),"$($RDSStatus.MemLoad)%",$htmlwhite))    
                                        $rowdata += @(,("Disk read time",($Script:htmlsb),"$($RDSStatus.DiskRead)%",$htmlwhite))    
                                        $rowdata += @(,("Disk write time",($Script:htmlsb),"$($RDSStatus.DiskWrite)%",$htmlwhite))    
                                        $rowdata += @(,("Sessions",($Script:htmlsb),$Sessions,$htmlwhite))    
                                        $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$RDSStatus.PreferredBroker,$htmlwhite))    
                                        $rowdata += @(,("Operating system",($Script:htmlsb),$RDSStatus.ServerOS,$htmlwhite))    
                                        $rowdata += @(,("Agent version",($Script:htmlsb),$RDSStatus.AgentVer,$htmlwhite))    
     
                                        $msg = ""    
                                        $columnWidths = @("200","350")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                        }    
                }    
        }    
     
        Write-Verbose "$(Get-Date -Format G): `tOutput Providers"    
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Providers"    
        }    
        If($Text)    
        {    
                Line 1 "Providers"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Providers"    
        }    
     
        $Providers = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Providers for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Providers for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Providers for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve Providers for Site $($Site.Name)"    
                }    
        }    
        ElseIf($? -and $Null -eq $Providers)    
        {    
                Write-Host "    
        No Providers retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Providers retrieved for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "No Providers retrieved for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Providers retrieved for Site $($Site.Name)"    
                }    
        }    
        Else    
        {    
                ForEach($Provider in $Providers)    
                {    
                        $Providerstatus = Get-RASProviderStatus -Id $Provider.Id -EA 0 4>$Null    
                            
                        If(!$?)    
                        {    
                                Write-Warning "    
                                `n    
                                Unable to retrieve VDI Host Status for VDI Host $($Provider.Id)`    
                                "    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($Provider.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "Unable to retrieve VDI Host Status for VDI Host $($Provider.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($Provider.Id)"    
                                }    
                        }    
                        ElseIf($? -and $Null -eq $Providerstatus)    
                        {    
                                Write-Host "    
                                No VDI Host Status retrieved for VDI Host $($Provider.Id)`    
                                " -ForegroundColor White    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "No VDI Host Status retrieved for VDI Host $($Provider.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "No VDI Host Status retrieved for VDI Host $($Provider.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "No VDI Host Status retrieved for VDI Host $($Provider.Id)"    
                                }    
                        }    
                        Else    
                        {    
                                $FullProviderStatus = GetRASStatus $Providerstatus.AgentState    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $Provider.Server; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $FullProviderStatus; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "CPU"; Value = "$($Providerstatus.CPULoad)%"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "RAM"; Value = "$($Providerstatus.MemLoad)%"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($Providerstatus.DiskRead)%"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($Providerstatus.DiskWrite)%"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Preferred COnnection Broker"; Value = $Providerstatus.PreferredBroker; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Operating system"; Value = $Providerstatus.ServerOS; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Agent version"; Value = $Providerstatus.AgentVer; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 300;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Name`t`t`t`t: " $Provider.Server    
                                        Line 2 "Status`t`t`t`t: " $FullProviderStatus    
                                        Line 2 "CPU`t`t`t`t: " "$($Providerstatus.CPULoad)%"    
                                        Line 2 "RAM`t`t`t`t: " "$($Providerstatus.MemLoad)%"    
                                        Line 2 "Disk read time`t`t`t: " "$($Providerstatus.DiskRead)%"    
                                        Line 2 "Disk write time`t`t`t: " "$($Providerstatus.DiskWrite)%"    
                                        Line 2 "Preferred Connection Broker`t: " $Providerstatus.PreferredBroker    
                                        Line 2 "Operating system`t`t: " $Providerstatus.ServerOS    
                                        Line 2 "Agent version`t`t`t: " $Providerstatus.AgentVer    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Name",($Script:htmlsb),$Provider.Server,$htmlwhite)    
                                        $rowdata += @(,("Status",($Script:htmlsb),$FullProviderStatus,$htmlwhite))    
                                        $rowdata += @(,("CPU",($Script:htmlsb),"$($Providerstatus.CPULoad)%",$htmlwhite))    
                                        $rowdata += @(,("RAM",($Script:htmlsb),"$($Providerstatus.MemLoad)%",$htmlwhite))    
                                        $rowdata += @(,("Disk read time",($Script:htmlsb),"$($Providerstatus.DiskRead)%",$htmlwhite))    
                                        $rowdata += @(,("Disk write time",($Script:htmlsb),"$($Providerstatus.DiskWrite)%",$htmlwhite))    
                                        $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$Providerstatus.PreferredBroker,$htmlwhite))    
                                        $rowdata += @(,("Operating system",($Script:htmlsb),$Providerstatus.ServerOS,$htmlwhite))    
                                        $rowdata += @(,("Agent version",($Script:htmlsb),$Providerstatus.AgentVer,$htmlwhite))    
     
                                        $msg = ""    
                                        $columnWidths = @("200","350")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                        }    
                }    
        }    
            
        Write-Verbose "$(Get-Date -Format G): `tOutput Secure Gateways"    
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Secure Gateways"    
        }    
        If($Text)    
        {    
                Line 1 "Secure Gateways"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Secure Gateways"    
        }    
     
        $SecureGateways = Get-RASGateway -Siteid $Site.Id -EA 0 4> $Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Secure Gateways for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"    
                }    
        }    
        ElseIf($? -and $Null -eq $SecureGateways)    
        {    
                Write-Host "    
        No Secure Gateways retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Secure Gateways retrieved for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "No Secure Gateways retrieved for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Secure Gateways retrieved for Site $($Site.Name)"    
                }    
        }    
        Else    
        {    
                ForEach($SecureGateway in $SecureGateways)    
                {    
                        $SecureGatewayStatus = Get-RASGatewayStatus -Id $SecureGateway.Id -EA 0 4>$Null    
                            
                        If(!$?)    
                        {    
                                Write-Warning "    
                                `n    
                                Unable to retrieve Gateway Status for Secure Gateway $($SecureGateway.Id)`    
                                "    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "Unable to retrieve Gateway Status for Secure Gateway $($SecureGateway.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "Unable to retrieve Gateway Status for Secure Gateway $($SecureGateway.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "Unable to retrieve Gateway Status for Secure Gateway $($SecureGateway.Id)"    
                                }    
                        }    
                        ElseIf($? -and $Null -eq $SecureGatewayStatus)    
                        {    
                                Write-Host "    
                                No Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)`    
                                " -ForegroundColor White    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "No Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "No Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "No Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)"    
                                }    
                        }    
                        Else    
                        {    
                                $Sessions = ($SecureGatewayStatus.ActiveRDPSessions + $SecureGatewayStatus.ActiveRDPSSLSessions)    
                                $SecureGatewayStatusAgentState = GetRASStatus $SecureGatewayStatus.AgentState    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $SecureGateway.Server; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $SecureGatewayStatusAgentState; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "CPU"; Value = "$($SecureGatewayStatus.CPULoad)%"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "RAM"; Value = "$($SecureGatewayStatus.MemLoad)%"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($SecureGatewayStatus.DiskRead)%"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($SecureGatewayStatus.DiskWrite)%"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Sessions"; Value = $Sessions.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $SecureGatewayStatus.PreferredBroker; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Operating system"; Value = $SecureGatewayStatus.ServerOS; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Agent version"; Value = $SecureGatewayStatus.AgentVer; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 300;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Name`t`t`t`t: " $SecureGateway.Server    
                                        Line 2 "Status`t`t`t`t: " $SecureGatewayStatusAgentState    
                                        Line 2 "CPU`t`t`t`t: " "$($SecureGatewayStatus.CPULoad)%"    
                                        Line 2 "RAM`t`t`t`t: " "$($SecureGatewayStatus.MemLoad)%"    
                                        Line 2 "Disk read time`t`t`t: " "$($SecureGatewayStatus.DiskRead)%"    
                                        Line 2 "Disk write time`t`t`t: " "$($SecureGatewayStatus.DiskWrite)%"    
                                        Line 2 "Sessions`t`t`t: " $Sessions.ToString()    
                                        Line 2 "Preferred Connection Broker`t: " $SecureGatewayStatus.PreferredBroker    
                                        Line 2 "Operating system`t`t: " $SecureGatewayStatus.ServerOS    
                                        Line 2 "Agent version`t`t`t: " $SecureGatewayStatus.AgentVer    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Name",($Script:htmlsb),$SecureGateway.Server,$htmlwhite)    
                                        $rowdata += @(,("Status",($Script:htmlsb),$SecureGatewayStatusAgentState.ToString(),$htmlwhite))    
                                        $rowdata += @(,("CPU",($Script:htmlsb),"$($SecureGatewayStatus.CPULoad)%",$htmlwhite))    
                                        $rowdata += @(,("RAM",($Script:htmlsb),"$($SecureGatewayStatus.MemLoad)%",$htmlwhite))    
                                        $rowdata += @(,("Disk read time",($Script:htmlsb),"$($SecureGatewayStatus.DiskRead)%",$htmlwhite))    
                                        $rowdata += @(,("Disk write time",($Script:htmlsb),"$($SecureGatewayStatus.DiskWrite)%",$htmlwhite))    
                                        $rowdata += @(,("Sessions",($Script:htmlsb),$Sessions.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$SecureGatewayStatus.PreferredBroker,$htmlwhite))    
                                        $rowdata += @(,("Operating system",($Script:htmlsb),$SecureGatewayStatus.ServerOS,$htmlwhite))    
                                        $rowdata += @(,("Agent version",($Script:htmlsb),$SecureGatewayStatus.AgentVer,$htmlwhite))    
     
                                        $msg = ""    
                                        $columnWidths = @("200","350")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                        }    
                }    
        }    
            
        Write-Verbose "$(Get-Date -Format G): `tOutput Connection Brokers"    
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Connection Brokers"    
        }    
        If($Text)    
        {    
                Line 1 "Connection Brokers"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Connection Brokers"    
        }    
     
        $ConnectionBrokers = Get-RASBroker -Siteid $Site.Id -EA 0 4> $Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Connection Brokers for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"    
                }    
        }    
        ElseIf($? -and $Null -eq $ConnectionBrokers)    
        {    
                Write-Host "    
        No Connection Brokers retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Connection Brokers retrieved for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "No Connection Brokers retrieved for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Connection Brokers retrieved for Site $($Site.Name)"    
                }    
        }    
        Else    
        {    
                ForEach($ConnectionBroker in $ConnectionBrokers)    
                {    
                        $ConnectionBrokerStatus = Get-RASBrokerStatus -Id $ConnectionBroker.Id -EA 0 4>$Null    
                            
                        If(!$?)    
                        {    
                                Write-Warning "    
                                `n    
                                Unable to retrieve Connection Brokers Status for Connection Brokers $($ConnectionBroker.Id)`    
                                "    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "Unable to retrieve Connection Brokers Status for Connection Brokers $($ConnectionBroker.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "Unable to retrieve Connection Brokers Status for Connection Brokers $($ConnectionBroker.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "Unable to retrieve Connection Brokers Status for Connection Brokers $($ConnectionBroker.Id)"    
                                }    
                        }    
                        ElseIf($? -and $Null -eq $ConnectionBrokerStatus)    
                        {    
                                Write-Host "    
                                No Connection Brokers Status retrieved for Connection Brokers $($ConnectionBroker.Id)`    
                                " -ForegroundColor White    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "No Connection Brokers Status retrieved for Connection Brokers $($ConnectionBroker.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "No Connection Brokers Status retrieved for Connection Brokers $($ConnectionBroker.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "No Connection Brokers Status retrieved for Connection Brokers $($ConnectionBroker.Id)"    
                                }    
                        }    
                        Else    
                        {    
                                If($ConnectionBroker.Priority -eq 0)    
                                {    
                                        $ConnectionBrokerPriority = "Primary"    
                                }    
                                Else    
                                {    
                                        $ConnectionBrokerPriority = "Secondary"    
                                }    
                                    
                                $ConnectionBrokerStatusAgentState = GetRASStatus $ConnectionBrokerStatus.AgentState    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $ConnectionBroker.Server; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Priority"; Value = $ConnectionBrokerPriority; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $ConnectionBrokerStatusAgentState; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "CPU"; Value = "$($ConnectionBrokerStatus.CPULoad)%"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "RAM"; Value = "$($ConnectionBrokerStatus.MemLoad)%"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($ConnectionBrokerStatus.DiskRead)%"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($ConnectionBrokerStatus.DiskWrite)%"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Operating system"; Value = $ConnectionBrokerStatus.ServerOS; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Agent version"; Value = $ConnectionBrokerStatus.AgentVer; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 300;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Name`t`t: " $ConnectionBroker.Server    
                                        Line 2 "Priority`t: " $ConnectionBrokerPriority    
                                        Line 2 "Status`t`t: " $ConnectionBrokerStatusAgentState    
                                        Line 2 "CPU`t`t: " "$($ConnectionBrokerStatus.CPULoad)%"    
                                        Line 2 "RAM`t`t: " "$($ConnectionBrokerStatus.MemLoad)%"    
                                        Line 2 "Disk read time`t: " "$($ConnectionBrokerStatus.DiskRead)%"    
                                        Line 2 "Disk write time`t: " "$($ConnectionBrokerStatus.DiskWrite)%"    
                                        Line 2 "Operating system: " $ConnectionBrokerStatus.ServerOS    
                                        Line 2 "Agent version`t: " $ConnectionBrokerStatus.AgentVer    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Name",($Script:htmlsb),$ConnectionBroker.Server,$htmlwhite)    
                                        $rowdata += @(,("Priority",($Script:htmlsb),$ConnectionBrokerPriority,$htmlwhite))    
                                        $rowdata += @(,("Status",($Script:htmlsb),$ConnectionBrokerStatusAgentState.ToString(),$htmlwhite))    
                                        $rowdata += @(,("CPU",($Script:htmlsb),"$($ConnectionBrokerStatus.CPULoad)%",$htmlwhite))    
                                        $rowdata += @(,("RAM",($Script:htmlsb),"$($ConnectionBrokerStatus.MemLoad)%",$htmlwhite))    
                                        $rowdata += @(,("Disk read time",($Script:htmlsb),"$($ConnectionBrokerStatus.DiskRead)%",$htmlwhite))    
                                        $rowdata += @(,("Disk write time",($Script:htmlsb),"$($ConnectionBrokerStatus.DiskWrite)%",$htmlwhite))    
                                        $rowdata += @(,("Operating system",($Script:htmlsb),$ConnectionBrokerStatus.ServerOS,$htmlwhite))    
                                        $rowdata += @(,("Agent version",($Script:htmlsb),$ConnectionBrokerStatus.AgentVer,$htmlwhite))    
     
                                        $msg = ""    
                                        $columnWidths = @("200","350")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                        }    
                }    
        }    
            
        Write-Verbose "$(Get-Date -Format G): `tOutput Enrollment Servers"    
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Enrollment Servers"    
        }    
        If($Text)    
        {    
                Line 1 "Enrollment Servers"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Enrollment Servers"    
        }    
     
        $EnrollmentServers = Get-RASEnrollmentServer -Siteid $Site.Id -EA 0 4> $Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Enrollment Servers for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Enrollment Servers for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Enrollment Servers for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve Enrollment Servers for Site $($Site.Name)"    
                }    
        }    
        ElseIf($? -and $Null -eq $EnrollmentServers)    
        {    
                Write-Host "    
        No Enrollment Servers retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Enrollment Servers retrieved for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "No Enrollment Servers retrieved for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Enrollment Servers retrieved for Site $($Site.Name)"    
                }    
        }    
        Else    
        {    
                ForEach($EnrollmentServer in $EnrollmentServers)    
                {    
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $EnrollmentServer.Server; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Status"; Value = "Can't find"; }) > $Null    
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                            Line 2 "Address`t`t: " $RDSHost.Server
                                            Line 2 "Status`t`t: " $RDSStatusAgentState
                                            Line 2 "CPU`t`t: " "$($RDSStatus.CPULoad)%"
                                            Line 2 "RAM`t`t: " "$($RDSStatus.MemLoad)%"
                                            Line 2 "Disk read time`t: " "$($RDSStatus.DiskRead)%"
                                            Line 2 "Disk write time`t: " "$($RDSStatus.DiskWrite)%"
                                            Line 2 "Sessions`t: " $Sessions
                                            Line 2 "Preferred PA`t: " $RDSStatus.PreferredPA
                                            Line 2 "Operating system: " $RDSStatus.ServerOS
                                            Line 2 "Agent version`t: " $RDSStatus.AgentVer
                                            Line 0 ""
                                    }
                                    If($HTML)
                                    {
                                            $rowdata = @()
                                            $columnHeaders = @("Address",($Script:htmlsb),$RDSHost.Server,$htmlwhite)
                                            $rowdata += @(,("Status",($Script:htmlsb),$RDSStatusAgentState,$htmlwhite))
                                            $rowdata += @(,("CPU",($Script:htmlsb),"$($RDSStatus.CPULoad)%",$htmlwhite))
                                            $rowdata += @(,("RAM",($Script:htmlsb),"$($RDSStatus.MemLoad)%",$htmlwhite))
                                            $rowdata += @(,("Disk read time",($Script:htmlsb),"$($RDSStatus.DiskRead)%",$htmlwhite))
                                            $rowdata += @(,("Disk write time",($Script:htmlsb),"$($RDSStatus.DiskWrite)%",$htmlwhite))
                                            $rowdata += @(,("Sessions",($Script:htmlsb),$Sessions,$htmlwhite))
                                            $rowdata += @(,("Preferred PA",($Script:htmlsb),$RDSStatus.PreferredPA,$htmlwhite))
                                            $rowdata += @(,("Operating system",($Script:htmlsb),$RDSStatus.ServerOS,$htmlwhite))
                                            $rowdata += @(,("Agent version",($Script:htmlsb),$RDSStatus.AgentVer,$htmlwhite))
     
                                            $msg = ""
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
                            }
                    }
            }
     
            $VDIHosts = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve VDI for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                                Line 3 "Name`t`t`t: " $EnrollmentServer.Server                           Line 0 "Unable to retrieve VDI for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $VDIHosts)
            {
                    Write-Host "
                    No VDI retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No VDI retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No VDI retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No VDI retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 "VDI Providers"
                    }
                    If($Text)
                    {
                            Line 1 "VDI Providers"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "VDI Providers"
                    }
     
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput VDI Providers"
                    ForEach($VDIHost in $VDIHosts)
                    {
                            $VDIHostStatus = Get-RASProviderStatus -Id $VDIHost.Id -EA 0 4>$Null
                            
                            If(!$?)
                            {
                                    Write-Warning "
                                    `n
                                    Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)`
                                    "
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)"
                                    }
                            }
                            ElseIf($? -and $Null -eq $VDIHostStatus)
                            {
                                    Write-Host "
                                    No VDI Host Status retrieved for VDI Host $($VDIHost.Id)`
                                    " -ForegroundColor White
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)"
                                    }
                            }
                            Else
                            {
                                    $FullProviderStatus = GetRASStatus $VDIHostStatus.AgentState
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Address"; Value = $VDIHost.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Status"; Value = $FullProviderStatus; }) > $Null
                                            $ScriptInformation.Add(@{Data = "CPU"; Value = "$($VDIHostStatus.CPULoad)%"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "RAM"; Value = "$($VDIHostStatus.MemLoad)%"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($VDIHostStatus.DiskRead)%"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($VDIHostStatus.DiskWrite)%"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Preferred PA"; Value = $VDIHostStatus.PreferredPA; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Operating system"; Value = $VDIHostStatus.ServerOS; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Agent version"; Value = $VDIHostStatus.AgentVer; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                                    If($Text)
                                    {
                                            Line 2 "Address`t`t: " $VDIHost.Server
                                Line 3 "Status`t`t`t: " "Can't find"                                           Line 2 "Status`t`t: " $FullProviderStatus
                                            Line 2 "CPU`t`t: " "$($VDIHostStatus.CPULoad)%"
                                            Line 2 "RAM`t`t: " "$($VDIHostStatus.MemLoad)%"
                                            Line 2 "Disk read time`t: " "$($VDIHostStatus.DiskRead)%"
                                            Line 2 "Disk write time`t: " "$($VDIHostStatus.DiskWrite)%"
                                            Line 2 "Preferred PA`t: " $VDIHostStatus.PreferredPA
                                            Line 2 "Operating system: " $VDIHostStatus.ServerOS
                                            Line 2 "Agent version`t: " $VDIHostStatus.AgentVer
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $rowdata = @()                                           $rowdata = @()
                                $columnHeaders = @("Name",($Script:htmlsb),$EnrollmentServer.Server,$htmlwhite)                                           $columnHeaders = @("Address",($Script:htmlsb),$VDIHost.Server,$htmlwhite)
                                $rowdata += @(,("Status",($Script:htmlsb),"Can't find",$htmlwhite))                                           $rowdata += @(,("Status",($Script:htmlsb),$FullProviderStatus,$htmlwhite))
                                            $rowdata += @(,("CPU",($Script:htmlsb),"$($VDIHostStatus.CPULoad)%",$htmlwhite))
                                            $rowdata += @(,("RAM",($Script:htmlsb),"$($VDIHostStatus.MemLoad)%",$htmlwhite))
                                            $rowdata += @(,("Disk read time",($Script:htmlsb),"$($VDIHostStatus.DiskRead)%",$htmlwhite))
                                            $rowdata += @(,("Disk write time",($Script:htmlsb),"$($VDIHostStatus.DiskWrite)%",$htmlwhite))
                                            $rowdata += @(,("Preferred PA",($Script:htmlsb),$VDIHostStatus.PreferredPA,$htmlwhite))
                                            $rowdata += @(,("Operating system",($Script:htmlsb),$VDIHostStatus.ServerOS,$htmlwhite))
                                            $rowdata += @(,("Agent version",($Script:htmlsb),$VDIHostStatus.AgentVer,$htmlwhite))
 
                                $msg = "" <>                                         $msg = ""
                                $columnWidths = @("200","275")                                           $columnWidths = @("200","275")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                                    }
 
  <>         $GWs = Get-RASGW -Siteid $Site.Id -EA 0 4> $Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Gateways for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Gateways for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $GWs)
            {
                    Write-Host "
                    No Gateways retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Gateways retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Gateways retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Gateways retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 "Gateways"
                    }
                    If($Text)
                    {
                            Line 1 "Gateways"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "Gateways"
                    }
     
        Write-Verbose "$(Get-Date -Format G): Output RD Session Hosts"                   Write-Verbose "$(Get-Date -Format G): `t`tOutput Site Gateways"
                    ForEach($GW in $GWs)
                    {
                            $GWStatus = Get-RASGWStatus -Id $GW.Id -EA 0 4>$Null
                            
                            If(!$?)
                            {
                                    Write-Warning "
                                    `n
                                    Unable to retrieve Gateway Status for Gateway $($GW.Id)`
                                    "
        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)"
                                    }
                            }
                            ElseIf($? -and $Null -eq $GWStatus)
                            {
                                    Write-Host "
                                    No Gateway Status retrieved for Gateway $($GW.Id)`
                                    " -ForegroundColor White
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "No Gateway Status retrieved for Gateway $($GW.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "No Gateway Status retrieved for Gateway $($GW.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "No Gateway Status retrieved for Gateway $($GW.Id)"
                                    }
                            }
                            Else
                            {
                                    $Sessions = ($GWStatus.ActiveRDPSessions + $GWStatus.ActiveRDPSSLSessions)
                                    $GWStatusAgentState = GetRASStatus $GWStatus.AgentState
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Address"; Value = $GW.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Status"; Value = $GWStatusAgentState; }) > $Null
                                            $ScriptInformation.Add(@{Data = "CPU"; Value = "$($GWStatus.CPULoad)%"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "RAM"; Value = "$($GWStatus.MemLoad)%"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($GWStatus.DiskRead)%"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($GWStatus.DiskWrite)%"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Sessions"; Value = $Sessions.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Preferred PA"; Value = $GWStatus.PreferredPA; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Operating system"; Value = $GWStatus.ServerOS; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Agent version"; Value = $GWStatus.AgentVer; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                                    If($Text)
                                    {
                                            Line 2 "Address`t`t: " $GW.Server
                                            Line 2 "Status`t`t: " $GWStatusAgentState
                                            Line 2 "CPU`t`t: " "$($GWStatus.CPULoad)%"
                                            Line 2 "RAM`t`t: " "$($GWStatus.MemLoad)%"
                                            Line 2 "Disk read time`t: " "$($GWStatus.DiskRead)%"
                                            Line 2 "Disk write time`t: " "$($GWStatus.DiskWrite)%"
                                            Line 2 "Sessions`t: " $Sessions.ToString()
                                            Line 2 "Preferred PA`t: " $GWStatus.PreferredPA
                                            Line 2 "Operating system: " $GWStatus.ServerOS
                                            Line 2 "Agent version`t: " $GWStatus.AgentVer
                                            Line 0 ""
                                    }
                                    If($HTML)
                                    {
                                            $rowdata = @()
                                            $columnHeaders = @("Address",($Script:htmlsb),$GW.Server,$htmlwhite)
                                            $rowdata += @(,("Status",($Script:htmlsb),$GWStatusAgentState.ToString(),$htmlwhite))
                                            $rowdata += @(,("CPU",($Script:htmlsb),"$($GWStatus.CPULoad)%",$htmlwhite))
                                            $rowdata += @(,("RAM",($Script:htmlsb),"$($GWStatus.MemLoad)%",$htmlwhite))
                                            $rowdata += @(,("Disk read time",($Script:htmlsb),"$($GWStatus.DiskRead)%",$htmlwhite))
                                            $rowdata += @(,("Disk write time",($Script:htmlsb),"$($GWStatus.DiskWrite)%",$htmlwhite))
                                            $rowdata += @(,("Sessions",($Script:htmlsb),$Sessions.ToString(),$htmlwhite))
                                            $rowdata += @(,("Preferred PA",($Script:htmlsb),$GWStatus.PreferredPA,$htmlwhite))
                                            $rowdata += @(,("Operating system",($Script:htmlsb),$GWStatus.ServerOS,$htmlwhite))
                                            $rowdata += @(,("Agent version",($Script:htmlsb),$GWStatus.AgentVer,$htmlwhite))
     
                                            $msg = ""
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
                            }
                    }
            }
            
            $PAs = Get-RASPA -Siteid $Site.Id -EA 0 4> $Null
            
            If(!$?)
 
  <>                 Write-Warning "
                    `n
                    Unable to retrieve Publishing Agents for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $PAs)
            {
                    Write-Host "
                    No Publishing Agents retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Publishing Agents retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Publishing Agents retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Publishing Agents retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    If($MSWord -or $PDF)
                    {
                WriteWordLine 2 0 "RD Session Hosts"                           WriteWordLine 2 0 "Publishing Agents"
        }                   }
        If($Text)                   If($Text)
        {                   {
                Line 1 "RD Session Hosts"                           Line 1 "Publishing Agents"
        }                   }
        If($HTML)                   If($HTML)
        {                   {
                WriteHTMLLine 2 0 "RD Session Hosts"                           WriteHTMLLine 2 0 "Publishing Agents"
        }                   }
 
  -+                 Write-Verbose "$(Get-Date -Format G): `t`tOutput Publishing Agents"
                    ForEach($PA in $PAs)
                    {
                            $PAStatus = Get-RASPAStatus -Id $PA.Id -EA 0 4>$Null
                            
                            If(!$?)
                            {
                                    Write-Warning "
                                    `n
                                    Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)`
                                    "
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)"
                                    }
                            }
                            ElseIf($? -and $Null -eq $PAStatus)
                            {
                                    Write-Host "
                                    No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)`
                                    " -ForegroundColor White
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)"
                                    }
                            }
                            Else
                            {
                                    $PAStatusAgentState = GetRASStatus $PAStatus.AgentState
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Address"; Value = $PA.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Status"; Value = $PAStatusAgentState; }) > $Null
                                            $ScriptInformation.Add(@{Data = "CPU"; Value = "$($PAStatus.CPULoad)%"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "RAM"; Value = "$($PAStatus.MemLoad)%"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($PAStatus.DiskRead)%"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($PAStatus.DiskWrite)%"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Operating system"; Value = $PAStatus.ServerOS; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Agent version"; Value = $PAStatus.AgentVer; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                                    If($Text)
                                    {
                                            Line 2 "Address`t`t: " $PA.Server
                                            Line 2 "Status`t`t: " $PAStatusAgentState
                                            Line 2 "CPU`t`t: " "$($PAStatus.CPULoad)%"
                                            Line 2 "RAM`t`t: " "$($PAStatus.MemLoad)%"
                                            Line 2 "Disk read time`t: " "$($PAStatus.DiskRead)%"
                                            Line 2 "Disk write time`t: " "$($PAStatus.DiskWrite)%"
                                            Line 2 "Operating system: " $PAStatus.ServerOS
                                            Line 2 "Agent version`t: " $PAStatus.AgentVer
                                            Line 0 ""
                                    }
                                    If($HTML)
                                    {
                                            $rowdata = @()
                                            $columnHeaders = @("Address",($Script:htmlsb),$PA.Server,$htmlwhite)
                                            $rowdata += @(,("Status",($Script:htmlsb),$PAStatusAgentState.ToString(),$htmlwhite))
                                            $rowdata += @(,("CPU",($Script:htmlsb),"$($PAStatus.CPULoad)%",$htmlwhite))
                                            $rowdata += @(,("RAM",($Script:htmlsb),"$($PAStatus.MemLoad)%",$htmlwhite))
                                            $rowdata += @(,("Disk read time",($Script:htmlsb),"$($PAStatus.DiskRead)%",$htmlwhite))
                                            $rowdata += @(,("Disk write time",($Script:htmlsb),"$($PAStatus.DiskWrite)%",$htmlwhite))
                                            $rowdata += @(,("Operating system",($Script:htmlsb),$PAStatus.ServerOS,$htmlwhite))
                                            $rowdata += @(,("Agent version",($Script:htmlsb),$PAStatus.AgentVer,$htmlwhite))
     
                                            $msg = ""
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
                            }
                    }
            }
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Hosts"
 
        No RD Session Hosts retrieved for Site $($Site.Name).` <>                 No RD Session Hosts retrieved for Site $($Site.Name).`
 
  -+                 If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 "RD Session Hosts"
                    }
                    If($Text)
                    {
                            Line 1 "RD Session Hosts"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "RD Session Hosts"
                    }
     
 
  -+                         Write-Verbose "$(Get-Date -Format G): `t`t`tOutput RD Session Host $($RDSHost.Server)"
 
  -+                                 $Status      = "N/A"
 
                                        $UPDDefault = (Get-RASRDSDefaultSettings -SiteId $Site.Id -Ea 0 4>$Null).UPDMode <>                                         $UPDDefault = (Get-RASRDSDefaultSettings -SiteId $Site.Id -Ea 0).UPDMode
 
                                Line 4 "Enable server in site`t: " $RDSHost.Enabled.ToString() <>                                 Line 4 "Enable server in site`t`t`t`t`t: " $RDSHost.Enabled.ToString()
                                Line 4 "Server`t`t`t: " $RDSHost.Server                                   Line 4 "Server`t`t`t`t`t`t`t: " $RDSHost.Server
                                Line 4 "Description`t`t: " $RDSHost.Description                                   Line 4 "Description`t`t`t`t`t`t: " $RDSHost.Description
                                Line 4 "Direct Address`t`t: " $RDSHost.DirectAddress                                   Line 4 "Direct Address`t`t`t`t`t`t: " $RDSHost.DirectAddress
 
                                                                "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; <>                                                                 "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break}
                                                                                                                                 $ReplaceRegisteredApplication = "False";    
                                                                                                                                 Break}    
                                                                "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";                                                                   "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}
                                                                                                                                 $ReplaceRegisteredApplication = "False";    
                                                                                                                                 Break}    
                                                                "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";                                                                   "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}
                                                                                                                                 $ReplaceRegisteredApplication = "True";    
                                                                                                                                 Break}    
                                                                Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($GroupDefaults.AllowURLAndMailRedirection)";                                                                   Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($GroupDefaults.AllowURLAndMailRedirection)"; Break}
                                                                                                                                 $ReplaceRegisteredApplication = "False";    
                                                                                                                                 Break}    
 
                                                                "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; <>                                                                 "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break}
                                                                $RDSAllowDragAndDrop = "True";    
                                                                Break}    
                                                                "Disabled"                      {$RDSDragAndDrop = "Disabled";                                                                   "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}
                                                                $RDSAllowDragAndDrop = "False";    
                                                                Break}    
                                                                "ClientToServer"        {$RDSDragAndDrop = "Client to server only";                                                                   "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}
                                                                $RDSAllowDragAndDrop = "True";    
                                                                Break}    
                                                                "ServerToClient"        {$RDSDragAndDrop = "Server to client only";                                                                   "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}
                                                                $RDSAllowDragAndDrop = "True";    
                                                                Break}    
                                                                Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($GroupDefaults.DragAndDropMode)";                                                                   Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($GroupDefaults.DragAndDropMode)"; Break}
                                                                $RDSAllowDragAndDrop = "False";    
                                                                Break}    
 
                                                        If($GroupDefaults.PreferredBrokerId -eq 0) <>                                                         If($GroupDefaults.PreferredPAId -eq 0)
 
                                                                $RDSPreferredPublishingAgent = (Get-RASBroker -Id $GroupDefaults.PreferredBrokerId -EA 0 4>$Null).Server <>                                                                 $RDSPreferredPublishingAgent = (Get-RASPA -Id $GroupDefaults.PreferredPAId -EA 0 4>$Null).Server
 
                                                                        "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; <>                                                                         "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break}
                                                                                                                                         $ReplaceRegisteredApplication = "False";    
                                                                                                                                         Break}    
                                                                        "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";                                                                           "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}
                                                                                                                                         $ReplaceRegisteredApplication = "False";    
                                                                                                                                         Break}    
                                                                        "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";                                                                           "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}
                                                                                                                                         $ReplaceRegisteredApplication = "True";    
                                                                                                                                         Break}    
                                                                        Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSDefaults.AllowURLAndMailRedirection)";                                                                           Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSDefaults.AllowURLAndMailRedirection)"; Break}
                                                                                                                                         $ReplaceRegisteredApplication = "False";    
                                                                                                                                         Break}    
 
                                                                        "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; <>                                                                         "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break}
                                                                        $RDSAllowDragAndDrop = "True";    
                                                                        Break}    
                                                                        "Disabled"                      {$RDSDragAndDrop = "Disabled";                                                                           "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}
                                                                        $RDSAllowDragAndDrop = "False";    
                                                                        Break}    
                                                                        "ClientToServer"        {$RDSDragAndDrop = "Client to server only";                                                                           "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}
                                                                        $RDSAllowDragAndDrop = "True";    
                                                                        Break}    
                                                                        "ServerToClient"        {$RDSDragAndDrop = "Server to client only";                                                                           "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}
                                                                        $RDSAllowDragAndDrop = "True";    
                                                                        Break}    
                                                                        Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSDefaults.DragAndDropMode)";                                                                           Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSDefaults.DragAndDropMode)"; Break}
                                                                        $RDSAllowDragAndDrop = "False";    
                                                                        Break}    
 
                                                                If($RDSDefaults.PreferredBrokerId -eq 0) <>                                                                 If($RDSDefaults.PreferredPAId -eq 0)
 
                                                                        $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSDefaults.PreferredBrokerId -EA 0 4>$Null).Server <>                                                                         $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSDefaults.PreferredPAId -EA 0 4>$Null).Server
 
                                                                $ReplaceRegisteredApplication          = "False" +-  
 
                                                                $RDSAllowDragAndDrop                   = "Enabled" +-  
 
                                                "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; <>                                                 "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break}
                                                                                                                 $ReplaceRegisteredApplication = "False";    
                                                                                                                 Break}    
                                                "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";                                                   "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}
                                                                                                                 $ReplaceRegisteredApplication = "False";    
                                                                                                                 Break}    
                                                "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";                                                   "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}
                                                                                                                 $ReplaceRegisteredApplication = "True";    
                                                                                                                 Break}    
                                                Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSHost.AllowURLAndMailRedirection)";                                                   Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSHost.AllowURLAndMailRedirection)"; Break}
                                                                                                                 $ReplaceRegisteredApplication = "False";    
                                                                                                                 Break}    
 
                                                "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; <>                                                 "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break}
                                                $RDSAllowDragAndDrop = "True";    
                                                Break}    
                                                "Disabled"                      {$RDSDragAndDrop = "Disabled";                                                   "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}
                                                $RDSAllowDragAndDrop = "False";    
                                                Break}    
                                                "ClientToServer"        {$RDSDragAndDrop = "Client to server only";                                                   "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}
                                                $RDSAllowDragAndDrop = "True";    
                                                Break}    
                                                "ServerToClient"        {$RDSDragAndDrop = "Server to client only";                                                   "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}
                                                $RDSAllowDragAndDrop = "True";    
                                                Break}    
                                                Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSHost.DragAndDropMode)";                                                   Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSHost.DragAndDropMode)"; Break}
                                                $RDSAllowDragAndDrop = "False";    
                                                Break}    
 
                                        If($RDSHost.PreferredBrokerId -eq 0) <>                                         If($RDSHost.PreferredPAId -eq 0)
 
                                                $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSHost.PreferredBrokerId -EA 0 4>$Null).Server <>                                                 $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSHost.PreferredPAId -EA 0 4>$Null).Server
 
                                        "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; <>                                         "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break}
                                                                                                         $ReplaceRegisteredApplication = "False";    
                                                                                                         Break}    
                                        "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";                                           "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}
                                                                                                         $ReplaceRegisteredApplication = "False";    
                                                                                                         Break}    
                                        "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";                                           "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}
                                                                                                         $ReplaceRegisteredApplication = "True";    
                                                                                                         Break}    
                                        Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSHost.AllowURLAndMailRedirection)";                                           Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSHost.AllowURLAndMailRedirection)"; Break}
                                                                                                         $ReplaceRegisteredApplication = "False";    
                                                                                                         Break}    
 
                                        "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; <>                                         "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break}
                                        $RDSAllowDragAndDrop = "True";    
                                        Break}    
                                        "Disabled"                      {$RDSDragAndDrop = "Disabled";                                           "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}
                                        $RDSAllowDragAndDrop = "False";    
                                        Break}    
                                        "ClientToServer"        {$RDSDragAndDrop = "Client to server only";                                           "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}
                                        $RDSAllowDragAndDrop = "True";    
                                        Break}    
                                        "ServerToClient"        {$RDSDragAndDrop = "Server to client only";                                           "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}
                                        $RDSAllowDragAndDrop = "True";    
                                        Break}    
                                        Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSHost.DragAndDropMode)";                                           Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSHost.DragAndDropMode)"; Break}
                                        $RDSAllowDragAndDrop = "False";    
                                        Break}    
 
                                If($RDSHost.PreferredBrokerId -eq 0) <>                                 If($RDSHost.PreferredPAId -eq 0)
 
                                        $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSHost.PreferredBrokerId -EA 0 4>$Null).Server <>                                         $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSHost.PreferredPAId -EA 0 4>$Null).Server
 
                                $ScriptInformation.Add(@{Data = "Application session lingering"; Value = ""; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "     Disconnect active session after"; Value = $RDSPublishingSessionDisconnectTimeout; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Logoff disconnected session after"; Value = $RDSPublishingSessionResetTime; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Other settings"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Port"; Value = $RDSPort; }) > $Null                                   $ScriptInformation.Add(@{Data = "Port"; Value = $RDSPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Max Sessions"; Value = $RDSMaxSessions; }) > $Null                                   $ScriptInformation.Add(@{Data = "Max Sessions"; Value = $RDSMaxSessions; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Publishing Session Disconnect Timeout"; Value = $RDSPublishingSessionDisconnectTimeout; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Preferred Connection Broker"; Value = $RDSPreferredPublishingAgent; }) > $Null                                   $ScriptInformation.Add(@{Data = "Publishing Session Reset Timeout"; Value = $RDSPublishingSessionResetTime; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "     Replace registered application"; Value = $ReplaceRegisteredApplication; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "     Support Windows Shell URL namespace objects"; Value = $RDSSupportShellURLNamespaceObject; }) > $Null                                   $ScriptInformation.Add(@{Data = "Support Windows Shell URL namespace objects"; Value = $RDSSupportShellURLNamespaceObject; }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable Drag and drop"; Value = $RDSAllowDragandDrop; }) > $Null                                   $ScriptInformation.Add(@{Data = "Drag and drop"; Value = $RDSDragAndDrop; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Direction"; Value = $RDSDragAndDrop; }) > $Null                                   $ScriptInformation.Add(@{Data = "Preferred Publishing Agent"; Value = $RDSPreferredPublishingAgent; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Allow file transfer command (Web (HTML5) and Chrome clients)"; Value = $RDSAllowFileTransfer; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Allow file transfer command (HTML5 and Chrome clients)"; Value = $RDSAllowFileTransfer; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Configure File Transfer"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Configure File Transfer"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Direction"; Value = $RDSFileTransferMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Direction"; Value = $RDSFileTransferMode; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Location"; Value = $RDSFileTransferLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Location"; Value = $RDSFileTransferLocation; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Do not allow to change location"; Value = $RDSFileTransferChangeLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Do not allow to change location"; Value = $RDSFileTransferChangeLocation; }) > $Null
 
                                Line 4 "Inherit default settings`t`t`t`t`t: " $RDSHost.InheritDefaultAgentSettings.ToString() <>                                 Line 4 "Inherit default settings`t`t`t`t: " $RDSHost.InheritDefaultAgentSettings.ToString()
                                Line 4 "Application session lingering"    
                                Line 5 "Disconnect active session after`t`t`t`t: " $RDSPublishingSessionDisconnectTimeout    
                                Line 5 "Logoff disconnected session after`t`t`t: " $RDSPublishingSessionResetTime    
                                Line 4 "Other settings"    
                                Line 5 "Port`t`t`t`t`t`t`t: " $RDSPort                                   Line 4 "Port`t`t`t`t`t`t`t: " $RDSPort
                                Line 5 "Max Sessions`t`t`t`t`t`t: " $RDSMaxSessions                                   Line 4 "Max Sessions`t`t`t`t`t`t: " $RDSMaxSessions
                                    Line 4 "Publishing Session Disconnect Timeout`t`t`t: " $RDSPublishingSessionDisconnectTimeout
                                Line 5 "Preferred Connection Broker`t`t`t`t: " $RDSPreferredPublishingAgent                                   Line 4 "Publishing Session Reset Timeout`t`t`t: " $RDSPublishingSessionResetTime
                                Line 4 "Allow Client URL/Mail Redirection`t`t`t`t: " $RDSAllowClientURLMailRedirection                                   Line 4 "Allow Client URL/Mail Redirection`t`t`t: " $RDSAllowClientURLMailRedirection
                                Line 5 "Replace registered application`t`t`t`t: " $ReplaceRegisteredApplication    
                                Line 5 "Support Windows Shell URL namespace objects`t`t: " $RDSSupportShellURLNamespaceObject                                   Line 4 "Support Windows Shell URL namespace objects`t`t: " $RDSSupportShellURLNamespaceObject
                                Line 4 "Enable Drag and drop`t`t`t`t`t`t: " $RDSAllowDragandDrop                                   Line 4 "Drag and drop`t`t`t`t`t`t: " $RDSDragAndDrop
                                Line 5 "Direction`t`t`t`t`t`t: " $RDSDragAndDrop                                   Line 4 "Preferred Publishing Agent`t`t`t`t: " $RDSPreferredPublishingAgent
                                Line 4 "Allow 2xRemoteExec to send command to the client`t`t: " $RDSAllowRemoteExec                                   Line 4 "Allow 2xRemoteExec to send command to the client`t: " $RDSAllowRemoteExec
                                Line 4 "Use RemoteApp if available`t`t`t`t`t: " $RDSUseRemoteApps                                   Line 4 "Use RemoteApp if available`t`t`t`t: " $RDSUseRemoteApps
                                Line 4 "Enable applications monitoring`t`t`t`t`t: " $RDSEnableAppMonitoring                                   Line 4 "Enable applications monitoring`t`t`t`t: " $RDSEnableAppMonitoring
                                Line 4 "Allow file transfer command (Web (HTML5) and Chrome clients)`t: " $RDSAllowFileTransfer                                   Line 4 "Allow file transfer command (HTML5 and Chrome clients)`t: " $RDSAllowFileTransfer
                                Line 5 "Configure File Transfer"                                   Line 4 "Configure File Transfer"
                                Line 6 "Direction`t`t`t: " $RDSFileTransferMode                                   Line 5 "Direction`t`t`t: " $RDSFileTransferMode
                                Line 6 "Location`t`t`t: " $RDSFileTransferLocation                                   Line 5 "Location`t`t`t: " $RDSFileTransferLocation
                                Line 6 "Do not allow to change location : " $RDSFileTransferChangeLocation                                   Line 5 "Do not allow to change location`t: " $RDSFileTransferChangeLocation
                                Line 4 "Enable drive redirection cache`t`t`t`t`t: " $RDSEnableDriveRedirectionCache                                   Line 4 "Enable drive redirection cache`t`t`t`t: " $RDSEnableDriveRedirectionCache
 
                                $rowdata += @(,("Application session lingering",($Script:htmlsb),"",$htmlwhite)) <>  
                                $rowdata += @(,("     Disconnect active session after",($Script:htmlsb),$RDSPublishingSessionDisconnectTimeout,$htmlwhite))    
                                $rowdata += @(,("     Logoff disconnected session after",($Script:htmlsb),$RDSPublishingSessionResetTime,$htmlwhite))    
                                $rowdata += @(,("Other settings",($Script:htmlsb),$RDSPort,$htmlwhite))    
                                $rowdata += @(,("     Port",($Script:htmlsb),$RDSPort,$htmlwhite))                                   $rowdata += @(,("Port",($Script:htmlsb),$RDSPort,$htmlwhite))
                                $rowdata += @(,("     Max Sessions",($Script:htmlsb),$RDSMaxSessions,$htmlwhite))                                   $rowdata += @(,("Max Sessions",($Script:htmlsb),$RDSMaxSessions,$htmlwhite))
                                    $rowdata += @(,("Publishing Session Disconnect Timeout",($Script:htmlsb),$RDSPublishingSessionDisconnectTimeout,$htmlwhite))
                                $rowdata += @(,("     Preferred Connection Broker",($Script:htmlsb),$RDSPreferredPublishingAgent,$htmlwhite))                                   $rowdata += @(,("Publishing Session Reset Timeout",($Script:htmlsb),$RDSPublishingSessionResetTime,$htmlwhite))
 
                                $rowdata += @(,("     Replace registered application",($Script:htmlsb),$ReplaceRegisteredApplication,$htmlwhite)) <>  
                                $rowdata += @(,("     Support Windows Shell URL namespace objects",($Script:htmlsb),$RDSSupportShellURLNamespaceObject,$htmlwhite))                                   $rowdata += @(,("Support Windows Shell URL namespace objects",($Script:htmlsb),$RDSSupportShellURLNamespaceObject,$htmlwhite))
                                $rowdata += @(,("Enable Drag and drop",($Script:htmlsb),$RDSAllowDragandDrop,$htmlwhite))                                   $rowdata += @(,("Drag and drop",($Script:htmlsb),$RDSDragAndDrop,$htmlwhite))
                                $rowdata += @(,("     Direction",($Script:htmlsb),$RDSDragAndDrop,$htmlwhite))                                   $rowdata += @(,("Preferred Publishing Agent",($Script:htmlsb),$RDSPreferredPublishingAgent,$htmlwhite))
 
                                $rowdata += @(,("Allow file transfer command (Web (HTML5) and Chrome clients)",($Script:htmlsb),$RDSAllowFileTransfer,$htmlwhite)) <>                                 $rowdata += @(,("Allow file transfer command (HTML5 and Chrome clients)",($Script:htmlsb),$RDSAllowFileTransfer,$htmlwhite))
                                $rowdata += @(,("     Configure File Transfer",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Configure File Transfer",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("          Direction",($Script:htmlsb),$RDSFileTransferMode,$htmlwhite))                                   $rowdata += @(,("     Direction",($Script:htmlsb),$RDSFileTransferMode,$htmlwhite))
                                $rowdata += @(,("          Location",($Script:htmlsb),$RDSFileTransferLocation,$htmlwhite))                                   $rowdata += @(,("     Location",($Script:htmlsb),$RDSFileTransferLocation,$htmlwhite))
                                $rowdata += @(,("          Do not allow to change location",($Script:htmlsb),$RDSFileTransferChangeLocation,$htmlwhite))                                   $rowdata += @(,("     Do not allow to change location",($Script:htmlsb),$RDSFileTransferChangeLocation,$htmlwhite))
 
                                                        #$FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate <>                                                         $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
 
                                                                #$FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate <>                                                                 $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
 
                                                                #$FSLogixDeploymentSettingsReplicate             = $False <>                                                                 $FSLogixDeploymentSettingsReplicate             = $False
 
                                        #$FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate <>                                         $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
 
                                #$FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate <>                                 $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
 
                                        #$ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null
 
                                        #Line 4 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString() <>                                         Line 4 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString()
 
                                        #$rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite)) <>                                         $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite))
 
                        #Optimization <>                         #Desktop Access
 
                                WriteWordLine 4 0 "Optimization" <>                                 WriteWordLine 4 0 "Desktop access"
 
                                Line 3 "Optimization" <>                                 Line 3 "Desktop access"
 
  <>                         
                        <#    
                        Get-RASImageOptimization -Id 1 -ObjType RDS    
     
                        EnableOptimization            : True    
                        OptimizationType              : Automatic    
                        WindowsDefenderATP            : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsDefenderATP    
                        WindowsComponents             : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsComponents    
                        WindowsDefenderATPEnabled     : True    
                        WindowsComponentsEnabled      : True    
                        WindowsServicesEnabled        : True    
                        WindowsScheduledTasksEnabled  : True    
                        WindowsAdvancedOptionsEnabled : True    
                        NetworkPerformanceEnabled     : True    
                        RegistryEnabled               : True    
                        VisualEffectsEnabled          : True    
                        DiskCleanupEnabled            : True    
                        CustomScriptEnabled           : False    
                        WindowsServices               : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsServices    
                        WindowsAdvancedOptions        : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsAdvancedOptions    
                        NetworkPerformance            : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.NetworkPerformance    
                        CustomScript                  : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.CustomScript    
                        DiskCleanup                   : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.DiskCleanup    
                        VisualEffects                 : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.VisualEffects    
                        WindowsScheduledTasks         : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsScheduledTasks    
                        Registry                      : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.Registries    
                        #>    
     
                        If($RDSHost.InheritDefaultOptimizationSettings)                           If($RDSHost.InheritDefaultDesktopAccessSettings)
 
                                $RDSGroup = Get-RASRDSGroup -SiteId $Site.Id -EA 0 4>$Null <>                                 $Results = Get-RASRDSGroup -SiteId $Site.Id -EA 0 4>$Null
 
                                If($? -and $Null -ne $RDSGroup) <>                                 If($? -and $Null -ne $Results)
 
                                        If($RDSGroup.RDSIds -Contains $RDSHost.Id ) <>                                         If($Results.RDSIds -Contains $RDSHost.Id )
 
                                                If($RDSGroup.InheritDefaultOptimizationSettings -eq $False) <>                                                 If($Results.InheritDefaultDesktopAccessSettings -eq $False)
 
                                                        $OPTEnableOptimization            = $RDSGroup.Optimization.EnableOptimization.ToString() <>                                                         $GroupDefaults = $Results.RDSDefSettings
                                                        $OPTOptimizationType              = $RDSGroup.Optimization.OptimizationType.ToString()    
                                                        $OPTWindowsDefenderATPEnabled     = $RDSGroup.Optimization.WindowsDefenderATPEnabled.ToString()                                                               $RDSRestrictDesktopAccess = $GroupDefaults.RestrictDesktopAccess.ToString()
                                                        $OPTWindowsComponentsEnabled      = $RDSGroup.Optimization.WindowsComponentsEnabled.ToString()                                                           $RDSRestrictedUsers       = @()
                                                        $OPTWindowsServicesEnabled        = $RDSGroup.Optimization.WindowsServicesEnabled.ToString()                                                          
                                                        $OPTWinodwsScheduledTasksEnabled  = $RDSGroup.Optimization.WindowsScheduledTasksEnabled.ToString()                                                           ForEach($User in $GroupDefaults.RestrictedUsers)
                                                        $OPTWindowsAdvancedOptionsEnabled = $RDSGroup.Optimization.WindowsAdvancedOptionsEnabled.ToString()                                                           {
                                                        $OPTNetworkPerformanceEnabled     = $RDSGroup.Optimization.NetworkPerformanceEnabled.ToString()    
                                                        $OPTRegistryEnabled               = $RDSGroup.Optimization.RegistryEnabled.ToString()                                                                   $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)
                                                        $OPTVisualEffectsEnabled          = $RDSGroup.Optimization.VisualEffectsEnabled.ToString()                                                                      $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
                                                        $OPTDiskCleanupEnabled            = $RDSGroup.Optimization.DiskCleanupEnabled.ToString()                                                                  
                                                        $OPTCustomScriptEnabled           = $RDSGroup.Optimization.CustomScriptEnabled.ToString()                                                                   $RDSRestrictedUsers += $objUser.Value
                                                            }
 
                                                                $OPTEnableOptimization            = $RDSDefaults.Optimization.EnableOptimization.ToString() <>                                                                 $RDSRestrictDesktopAccess = $RDSDefaults.RestrictDesktopAccess.ToString()
                                                                $OPTOptimizationType              = $RDSDefaults.Optimization.OptimizationType.ToString()                                                                   $RDSRestrictedUsers       = @()
                                                                $OPTWindowsDefenderATPEnabled     = $RDSDefaults.Optimization.WindowsDefenderATPEnabled.ToString()                                                                      
                                                                $OPTWindowsComponentsEnabled      = $RDSDefaults.Optimization.WindowsComponentsEnabled.ToString()                                                                   ForEach($User in $RDSDefaults.RestrictedUsers)
                                                                $OPTWindowsServicesEnabled        = $RDSDefaults.Optimization.WindowsServicesEnabled.ToString()                                                                   {
                                                                $OPTWinodwsScheduledTasksEnabled  = $RDSDefaults.Optimization.WindowsScheduledTasksEnabled.ToString()    
                                                                $OPTWindowsAdvancedOptionsEnabled = $RDSDefaults.Optimization.WindowsAdvancedOptionsEnabled.ToString()    
                                                                $OPTNetworkPerformanceEnabled     = $RDSDefaults.Optimization.NetworkPerformanceEnabled.ToString()    
                                                                $OPTRegistryEnabled               = $RDSDefaults.Optimization.RegistryEnabled.ToString()                                                                           $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)
                                                                $OPTVisualEffectsEnabled          = $RDSDefaults.Optimization.VisualEffectsEnabled.ToString()       
                                                                $OPTDiskCleanupEnabled            = $RDSDefaults.Optimization.DiskCleanupEnabled.ToString()    
                                                                $OPTCustomScriptEnabled           = $RDSDefaults.Optimization.CustomScriptEnabled.ToString()                                                                           $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
                                                                            
                                                                            $RDSRestrictedUsers += $objUser.Value
                                                                    }
 
                                                                $OPTEnableOptimization            = "False" <>  
                                                                $OPTOptimizationType              = ""    
                                                                $OPTWindowsDefenderATPEnabled     = "False"    
                                                                $OPTWindowsComponentsEnabled      = "False"    
                                                                $OPTWindowsServicesEnabled        = "False"    
                                                                $OPTWinodwsScheduledTasksEnabled  = "False"    
                                                                $OPTWindowsAdvancedOptionsEnabled = "False"    
                                                                $OPTNetworkPerformanceEnabled     = "False"    
                                                                $OPTRegistryEnabled               = "False"    
                                                                $OPTVisualEffectsEnabled          = "False"    
                                                                $OPTDiskCleanupEnabled            = "False"    
                                                                $OPTCustomScriptEnabled           = "False"                                                                   $RDSRestrictDesktopAccess = "False"
                                                                    $RDSRestrictedUsers       = @()
 
  -+                                         $RDSRestrictDesktopAccess = $RDSHost.RestrictDesktopAccess.ToString()
                                            $RDSRestrictedUsers       = @()
 
                                        $OPTEnableOptimization            = $RDSHost.Optimization.EnableOptimization.ToString() <>                                         ForEach($User in $RDSHost.RestrictedUsers)
                                        $OPTOptimizationType              = $RDSHost.Optimization.OptimizationType.ToString()                                           {
                                        $OPTWindowsDefenderATPEnabled     = $RDSHost.Optimization.WindowsDefenderATPEnabled.ToString()        
                                        $OPTWindowsComponentsEnabled      = $RDSHost.Optimization.WindowsComponentsEnabled.ToString()    
                                        $OPTWindowsServicesEnabled        = $RDSHost.Optimization.WindowsServicesEnabled.ToString()    
                                        $OPTWinodwsScheduledTasksEnabled  = $RDSHost.Optimization.WindowsScheduledTasksEnabled.ToString()    
                                        $OPTWindowsAdvancedOptionsEnabled = $RDSHost.Optimization.WindowsAdvancedOptionsEnabled.ToString()    
                                        $OPTNetworkPerformanceEnabled     = $RDSHost.Optimization.NetworkPerformanceEnabled.ToString()    
                                        $OPTRegistryEnabled               = $RDSHost.Optimization.RegistryEnabled.ToString()                                                   $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)
                                        $OPTVisualEffectsEnabled          = $RDSHost.Optimization.VisualEffectsEnabled.ToString()       
                                        $OPTDiskCleanupEnabled            = $RDSHost.Optimization.DiskCleanupEnabled.ToString()    
                                        $OPTCustomScriptEnabled           = $RDSHost.Optimization.CustomScriptEnabled.ToString()                                                   $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
                                                    
                                                    $RDSRestrictedUsers += $objUser.Value
                                            }
 
  -+                                 $RDSRestrictDesktopAccess = $RDSHost.RestrictDesktopAccess.ToString()
                                    $RDSRestrictedUsers       = @()
 
                                $OPTEnableOptimization            = $RDSHost.Optimization.EnableOptimization.ToString() <>                                 ForEach($User in $RDSHost.RestrictedUsers)
                                $OPTOptimizationType              = $RDSHost.Optimization.OptimizationType.ToString()                                   {
                                $OPTWindowsDefenderATPEnabled     = $RDSHost.Optimization.WindowsDefenderATPEnabled.ToString()        
                                $OPTWindowsComponentsEnabled      = $RDSHost.Optimization.WindowsComponentsEnabled.ToString()    
                                $OPTWindowsServicesEnabled        = $RDSHost.Optimization.WindowsServicesEnabled.ToString()    
                                $OPTWinodwsScheduledTasksEnabled  = $RDSHost.Optimization.WindowsScheduledTasksEnabled.ToString()    
                                $OPTWindowsAdvancedOptionsEnabled = $RDSHost.Optimization.WindowsAdvancedOptionsEnabled.ToString()    
                                $OPTNetworkPerformanceEnabled     = $RDSHost.Optimization.NetworkPerformanceEnabled.ToString()    
                                $OPTRegistryEnabled               = $RDSHost.Optimization.RegistryEnabled.ToString()                                           $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)
                                $OPTVisualEffectsEnabled          = $RDSHost.Optimization.VisualEffectsEnabled.ToString()       
                                $OPTDiskCleanupEnabled            = $RDSHost.Optimization.DiskCleanupEnabled.ToString()    
                                $OPTCustomScriptEnabled           = $RDSHost.Optimization.CustomScriptEnabled.ToString()                                           $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
                                            
                                            $RDSRestrictedUsers += $objUser.Value
                        }                                   }
                            }
                                    
 
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $RDSHost.InheritDefaultUserProfileSettings.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $RDSHost.InheritDefaultDesktopAccessSettings.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable optimization"; Value = $OPTEnableOptimization; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Optimization type"; Value = $OPTOptimizationType; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 250;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
     
                                WriteWordLine 5 0 "Windows Defender ATP:" $OPTWindowsDefenderATPEnabled    
                                If($OPTWindowsDefenderATPEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Windows Defender ATP Optimizations"; Value = ""; }) > $Null    
     
                                        If($RDSHost.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "     Turn off Windows Defender ATP (I use my own ATP solution)"; Value = ""; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = "     Turn on Windows Defender ATP and set process and folder exclusions"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Restrict direct desktop access to the following users"; Value = $RDSRestrictDesktopAccess; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Disable real-time protection"; Value = $RDSHost.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(); }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                                                  
                                                $cnt = -1                                   $cnt = -1
                                                ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeFolders)                                   ForEach($Item in $RDSRestrictedUsers)
                                                {                                   {
                                                        $cnt++                                           $cnt++
                                                        If($cnt -eq 0)                                           If($cnt -eq 0)
                                                        {                                           {
                                                                $ScriptInformation.Add(@{Data = "     Exclude files and folders"; Value = $item; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null                                                   $ScriptInformation.Add(@{Data = "Users"; Value = $Item; }) > $Null
                                                        }                                           }
                                                }    
     
                                                $cnt = -1    
                                                ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeProcesses)    
                                                {    
                                                        $cnt++    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "     Exclude processes"; Value = $item; }) > $Null    
                                                        }    
                                                        Else                                           Else
                                                        {                                           {
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                                        }                                           }
                                                }                                   }
                                                    
                                                $cnt = -1    
                                                ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeExtension)    
                                                {    
                                                        $cnt++    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "     Exclude extensions"; Value = $item; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null    
                                                        }    
                                                }    
                                        }    
 
                                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                        -Columns Data,Value `                                   -Columns Data,Value `
                                        -List `                                   -List `
                                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                                        #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                        $Table.Columns.Item(1).Width = 250; <>                                 $Table.Columns.Item(1).Width = 250;
                                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                                        $Table = $Null                                   $Table = $Null
                                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                                }                           }
     
                                WriteWordLine 5 0 "Windows Components:" $OPTWindowsComponentsEnabled    
                                If($OPTWindowsComponentsEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Windows Components Optimizations"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Disable (remove) components:"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        ForEach($item in $RDSHost.Optimization.WindowsComponents.WindowsComponentsList)    
                                        {    
                                                        If($Null -eq $item.DisplayName)    
                                                        {    
                                                                $DisplayName = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $DisplayName = $item.DisplayName    
                                                        }    
                                                        If($Null -eq $item.ComponentName)    
                                                        {    
                                                                $ComponentName = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ComponentName = $item.ComponentName    
                                                        }    
                                                $OptimizationTable += @{    
                                                        DisplayName = $DisplayName    
                                                        ComponentName = $ComponentName    
                                                }    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns DisplayName, ComponentName `    
                                                -Headers "Display name", "Component" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 200;    
                                                $Table.Columns.Item(2).Width = 200;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
     
                                WriteWordLine 5 0 "Windows Services: " $OPTWindowsServicesEnabled           
                                If($OPTWindowsServicesEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Windows Services Optimizations"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Disable services:"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        ForEach($item in $RDSHost.Optimization.WindowsServices.WindowsServicesList)    
                                        {    
                                                        If($Null -eq $item.DisplayName)    
                                                        {    
                                                                $DisplayName = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $DisplayName = $item.DisplayName    
                                                        }    
                                                        If($Null -eq $item.ServiceName)    
                                                        {    
                                                                $Service = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $Service = $item.ServiceName    
                                                        }    
                                                        If($Null -eq $item.Aliases)    
                                                        {    
                                                                $Aliases = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $Aliases = $item.Aliases    
                                                        }    
                                                $OptimizationTable += @{    
                                                        DisplayName = $DisplayName    
                                                        Service     = $Service    
                                                        Aliases     = $Aliases    
                                                }    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns DisplayName, Service, Aliases `    
                                                -Headers "Display name", "Service", "Aliases" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 200;    
                                                $Table.Columns.Item(2).Width = 100;    
                                                $Table.Columns.Item(3).Width = 50;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
                                    
                                WriteWordLine 5 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled     
                                If($OPTWinodwsScheduledTasksEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Windows Scheduled Tasks Optimizations"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Disable tasks:"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        ForEach($item in $RDSHost.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)    
                                        {    
                                                        If($Null -eq $item.Task)    
                                                        {    
                                                                $Task = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $Task = $item.Task    
                                                        }    
                                                        If($Null -eq $item.Type)    
                                                        {    
                                                                $Type = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $Type = $item.Type.ToString()    
                                                        }    
                                                        If($Null -eq $item.Location)    
                                                        {    
                                                                $Location = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $Location = $item.Location    
                                                        }    
                                                $OptimizationTable += @{    
                                                        Task     = $Task    
                                                        Type     = $Type    
                                                        Location = $Location    
                                                }    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns Task, Type, Location `    
                                                -Headers "Task", "Type", "Location" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 200;    
                                                $Table.Columns.Item(2).Width = 50;    
                                                $Table.Columns.Item(3).Width = 250;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
                                    
                                WriteWordLine 5 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled    
                                If($OPTWindowsAdvancedOptionsEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Windows Advanced Options"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        $OptimizationTable += @{    
                                                Setting = "Disable Hibernate"    
                                                Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.Hibernate.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable Telemetry collection"    
                                                Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.TeleCollection.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable System Restore"    
                                                Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.SystemRestore.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable error reporting to send additional data"    
                                                Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable Tiles"    
                                                Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.Tiles.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable Cortana digital assistant"    
                                                Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.Cortana.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Turn off Microsoft consumer experience"    
                                                Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Do not show Windows tips"    
                                                Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.WindowsTips.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Remove Common program groups from the Start Menu"    
                                                Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Partial Start Menu layout"    
                                                Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString()    
                                                Value   = $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns Setting, Enabled, Value `    
                                                -Headers "Setting", "Enabled", "Value" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 275;    
                                                $Table.Columns.Item(2).Width = 50;    
                                                $Table.Columns.Item(3).Width = 175;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
                                    
                                WriteWordLine 5 0 "Network performance: " $OPTNetworkPerformanceEnabled    
                                If($OPTNetworkPerformanceEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Network Performance Optimizations"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        $OptimizationTable += @{    
                                                Setting = "FileInfoCacheEntriesMax"    
                                                Enabled = $RDSHost.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString()    
                                                Value   = $RDSHost.Optimization.NetworkPerformance.FileInfoCache    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "DirectoryCacheEntriesMax"    
                                                Enabled = $RDSHost.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString()    
                                                Value   = $RDSHost.Optimization.NetworkPerformance.DirCacheMax    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "FileNotFoundCacheEntriesMax"    
                                                Enabled = $RDSHost.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString()    
                                                Value   = $RDSHost.Optimization.NetworkPerformance.FileNotFoundCache    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "DormantFileLimit"    
                                                Enabled = $RDSHost.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString()    
                                                Value   = $RDSHost.Optimization.NetworkPerformance.DormantFileLimit    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable TCP/IP Task Offload"    
                                                Enabled = $RDSHost.Optimization.NetworkPerformance.DisableTCP.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable IPv6 Components"    
                                                Enabled = $RDSHost.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable IPv6 to IPv4"    
                                                Enabled = $RDSHost.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disables isatap for IPv6"    
                                                Enabled = $RDSHost.Optimization.NetworkPerformance.DisableIsaTap.ToString()    
                                                Value   = ""    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns Setting, Enabled, Value `    
                                                -Headers "Setting", "Enabled", "Value" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 150;    
                                                $Table.Columns.Item(2).Width = 50;    
                                                $Table.Columns.Item(3).Width = 50;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
     
                                WriteWordLine 5 0 "Registry: " $OPTRegistryEnabled    
                                If($OPTRegistryEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Registry Optimizations"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
     
                                        ForEach($item in $RDSHost.Optimization.Registry.RegistryList)    
                                        {    
                                                If($item.RegType.ToString() -eq "REG_SZ" -or $item.RegType.ToString() -eq "REG_EXPAND_SZ")    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType.ToString(); }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Data"; Value = $item.StringValue; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                }    
                                                ElseIf($item.RegType.ToString() -eq "REG_DWORD" -or $item.RegType.ToString() -eq "REG_QWORD")    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType.ToString(); }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Data"; Value = $item.DWORDValue; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                }    
                                                ElseIf($item.RegType.ToString() -eq "REG_MULTI_SZ")    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null    
                                                        $cnt = -1    
                                                        $TmpArray = $item.StringValue.Split("`r")    
                                                        ForEach($SubItem in $TmpArray)    
                                                        {    
                                                                $cnt++    
                                                                    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = "Type"; Value = $SubItem; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = $SubItem; }) > $Null    
                                                                }    
                                                        }    
                                                        $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                }    
                                        }    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 125;    
                                        $Table.Columns.Item(2).Width = 375;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                    
                                WriteWordLine 5 0 "Visual Effects: " $OPTVisualEffectsEnabled    
                                If($OPTVisualEffectsEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Visual Effects Optimizations"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        $OptimizationTable += @{    
                                                Setting = "Animate controls and elements inside windows"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.AnimateControlSelectElements.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Animate windows when minimizing and maximizing"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Animations in the taskbar"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.AnimateTaskbar.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Enable Peek"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.EnablePeek.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Fade or slide menus into view"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.FadeSlideMenus.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Fade or slide Tooltips into view"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.FadeSlideToolTips.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Fade out menu items after clicking"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.FadeOutMenuItems.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Save taskbar thumbnail previews"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Show shadows under mouse pointer"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.ShowShadowUnderMouse.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Show shadows under windows"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.ShadowUnderWindows.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Show thumbnails instead of icons"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Show translucent selection rectangle"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.ShowTranslucentSelection.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Show window contents while dragging"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Slide open combo boxes"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.SlideOpenComboBoxes.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Smooth edges of screen fonts"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Smooth-scroll list boxes"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.SmoothScrollListBoxes.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Use drop shadows for icon labels on the desktop"    
                                                Enabled = $RDSHost.Optimization.VisualEffects.DropShadowsIcon.ToString()    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns Setting, Enabled `    
                                                -Headers "Setting", "Enabled" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 250;    
                                                $Table.Columns.Item(2).Width = 50;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
                                    
                                WriteWordLine 5 0 "Disk cleanup: " $OPTDiskCleanupEnabled    
                                If($OPTDiskCleanupEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Disk Cleanup Optimizations"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        $OptimizationTable += @{    
                                                Setting = "Clean up redundant system files"    
                                                Enabled = $RDSHost.Optimization.DiskCleanup.CleanupSystemFiles.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Clean up the WinSxS Folder"    
                                                Enabled = $RDSHost.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Clean up temporary files and logs"    
                                                Enabled = $RDSHost.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Remove OneDrive"    
                                                Enabled = $RDSHost.Optimization.DiskCleanup.RemoveOneDrive.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Delete users' profiles"    
                                                Enabled = $RDSHost.Optimization.DiskCleanup.DeleteUserProfiles.ToString()    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns Setting, Enabled `    
                                                -Headers "Setting", "Enabled" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 175;    
                                                $Table.Columns.Item(2).Width = 50;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
     
                                WriteWordLine 5 0 "Custom script: " $OPTCustomScriptEnabled    
                                If($OPTCustomScriptEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Custom Script"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Command"; Value = $RDSHost.Optimization.CustomScript.Command; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Arguments"; Value = $RDSHost.Optimization.CustomScript.Arguments; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Initial directory"; Value = $RDSHost.Optimization.CustomScript.InitDir; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Username"; Value = $RDSHost.Optimization.CustomScript.User; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 100;    
                                        $Table.Columns.Item(2).Width = 200;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                        }    
                        If($Text)    
                        {    
                                Line 4 "Inherit default settings`t: " $RDSHost.InheritDefaultOptimizationSettings.ToString()    
                                Line 4 "Enable optimization`t`t: " $OPTEnableOptimization    
                                Line 4 "Optimization type`t`t: " $OPTOptimizationType    
                                Line 4 "Category"    
                                    
                                Line 5 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled    
                                If($OPTWindowsDefenderATPEnabled -eq "True")    
                                {    
                                        Line 6 "Windows Defender ATP Optimizations"    
                                        <#    
                                                WinDefATPTurnOffOn        : TurnOnWindowsDefenderATP    
                                                DisableRealTimeProtection : False    
                                                ExcludeFolders            : {%ProgramData%\Parallels\RASLogs\, %ProgramFiles(x86)%\Parallels\,    
                                                                                                        %ProgramFiles%\Parallels\, %WINDOWS%\system32\config\...}    
                                                ExcludeProcesses          : {csrss.exe, winlogon.exe, rdpclip.exe, rdpinit.exe...}    
                                                ExcludeExtension          : {.vhd, .vhdx}                                           
                                        #>    
                                        If($RDSHost.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")    
                                        {    
                                                Line 7 "Turn off Windows Defender ATP (I use my own ATP solution)"    
                                        }    
                                        Else    
                                        {    
                                                Line 7 "Turn on Windows Defender ATP and set process and folder exclusions"    
                                                Line 7 "Disable real-time protection: " $RDSHost.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString()    
                                                Line 0 ""    
                                                Line 7 "Exclude files and folders:"    
                                                ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeFolders)    
                                                {    
                                                        Line 8 $item    
                                                }    
     
                                                Line 7 "Exclude processes:"    
                                                ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeProcesses)    
                                                {    
                                                        Line 8 $item    
                                                }    
                                                    
                                                Line 7 "Exclude extensions:"    
                                                ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeExtension)    
                                                {    
                                                        Line 8 $item    
                                                }    
                                        }    
                                            
                                        Line 0 ""    
                                }    
                                    
                                Line 5 "Windows Components: " $OPTWindowsComponentsEnabled    
                                If($OPTWindowsComponentsEnabled -eq "True")    
                                {    
                                        Line 6 "Windows Components Optimizations"    
                                        Line 7 "Disable (remove) components:"    
                                        Line 0 ""    
                                        Line 7 "Display name                                        Component                                         "    
                                        Line 7 "======================================================================================================"    
                                        #               12345678901234567890123456789012345678901234567890SS12345678901234567890123456789012345678901234567890    
                                        #               Printing-XPSServices-Features                       SMB 1.0/CIFS File sharing support component    
                                        <#    
                                                          Type ComponentName                 DisplayName Aliases    
                                                          ---- -------------                 ----------- -------    
                                                Predefined MSRDC-Infrastructure    
                                                Predefined MediaPlayback    
                                                Predefined WindowsMediaPlayer    
                                                Predefined Printing-XPSServices-Features    
                                                Predefined SMB1Protocol    
                                                Predefined SearchEngine-Client-Package    
                                                Predefined Xps-Foundation-Xps-Viewer                                        
                                        #>    
                                        ForEach($item in $RDSHost.Optimization.WindowsComponents.WindowsComponentsList)    
                                        {    
                                                Line 7 ( "{0,-50}  {1,-50}" -f $item.DisplayName, $item.ComponentName)    
                                        }    
                                        Line 0 ""    
                                }    
                                    
                                Line 5 "Windows Services: " $OPTWindowsServicesEnabled           
                                If($OPTWindowsServicesEnabled -eq "True")    
                                {    
                                        Line 6 "Windows Services Optimizations"    
                                        Line 7 "Disable services:"    
                                        Line 0 ""    
                                        Line 7 "Display name                                        Service                         Aliases             "    
                                        Line 7 "========================================================================================================"    
                                        #               12345678901234567890123456789012345678901234567890SS123456789012345678901234567890SS12345678901234567890    
                                        #               Windows Media Player Network Sharing Service        TabletInputService              Superfecth    
                                        <#    
                                                          Type ServiceName        DisplayName Aliases    
                                                          ---- -----------        ----------- -------    
                                                Predefined AJRouter    
                                                Predefined ALG    
                                                Predefined BTAGService    
                                                Predefined BthAvctpSvc    
                                                Predefined CscService    
                                                Predefined DOT3SVC    
                                                Predefined DPS    
                                                Predefined DiagTrack    
                                                Predefined EFS    
                                                Predefined FDResPub    
                                                Predefined MapsBroker    
                                                Predefined SSDPSRV    
                                                Predefined SensrSvc    
                                                Predefined SharedAccess    
                                                Predefined ShellHWDetection    
                                                Predefined StorSvc    
                                                Predefined Sysmain    
                                                Predefined Superfetch    
                                                Predefined TabletInputService    
                                                Predefined TapiSrv    
                                                Predefined Themes    
                                                Predefined WMPNetworkSvc    
                                                Predefined WbioSrvc    
                                                Predefined WdiSystemHost    
                                                Predefined WerSvc    
                                                Predefined bthserv    
                                                Predefined fdPHost    
                                                Predefined lfsvc    
                                                Predefined upnphost    
                                                Predefined wbengine    
                                                Predefined wisvc    
                                                Predefined wlidsvc                                          
                                        #>    
                                        ForEach($item in $RDSHost.Optimization.WindowsServices.WindowsServicesList)    
                                        {    
                                                Line 7 ( "{0,-50}  {1,-30}  {2,-20}" -f $item.DisplayName, $item.ServiceName, $item.Aliases)    
                                        }    
                                        Line 0 ""    
                                }    
                                    
                                Line 5 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled     
                                If($OPTWinodwsScheduledTasksEnabled -eq "True")    
                                {    
                                        Line 6 "Windows Scheduled Tasks Optimizations"    
                                        Line 7 "Disable tasks:"    
                                        Line 0 ""    
                                        Line 7 "Task                                                Type    Location                                          "    
                                        Line 7 "=============================================================================================================="    
                                        #               12345678901234567890123456789012345678901234567890SS123456SS12345678901234567890123456789012345678901234567890    
                                        #               MNO Metadata Parser                                 Folder  \Microsoft\Windows\Mobile Broadband Accounts\    
                                        <#    
                                                Task                Location                                        Type    
                                                ----                --------                                        ----    
                                                *                   \Microsoft\Windows\Application Experience     Folder    
                                                *                   \Microsoft\Windows\BitLocker                  Folder    
                                                CDSSync             \Microsoft\Windows\WlanSvc\                     Task    
                                                *                   \Microsoft\OneCore\DirectX                    Folder    
                                                GatherNetworkInfo   \Microsoft\Windows\NetTrace\                    Task    
                                                MNO Metadata Parser \Microsoft\Windows\Mobile Broadband Accounts\   Task    
                                                NotificationTask    \Microsoft\Windows\WwanSvc\                     Task    
                                                *                   \Microsoft\Office                             Folder    
                                                QueueReporting      \Microsoft\Windows\Windows Error Reporting\     Task    
                                                SR                  \Microsoft\Windows\SystemRestore\               Task    
                                                ScheduledDefrag     \Microsoft\Windows\Defrag\                      Task    
                                                Scheduled Start     \Microsoft\Windows\WindowsUpdate\               Task    
                                                *                   \Microsoft\Windows\Sysmain                    Folder    
                                                Tpm-HASCertRetr     \Microsoft\Windows\TPM\                         Task    
                                                Tpm-Maintenance     \Microsoft\Windows\TPM\                         Task    
                                                UninstallDeviceTask \Microsoft\Windows\Bluetooth\                   Task    
                                                UpdateLibrary       \Microsoft\Windows\Windows Media Sharing\       Task    
                                                *                   \Microsoft\Windows\Windows Defender           Folder    
                                                XblGameSaveTask     \Microsoft\XblGameSave\                         Task    
                                                sihpostreboot       \Microsoft\Windows\WindowsUpdate\               Task                                            
                                        #>    
                                        ForEach($item in $RDSHost.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)    
                                        {    
                                                Line 7 ( "{0,-50}  {1,-6}  {2,-50}" -f $item.Task, $item.Type.ToString(), $item.Location)    
                                        }    
                                        Line 0 ""    
                                }    
     
                                Line 5 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled    
                                If($OPTWindowsAdvancedOptionsEnabled -eq "True")    
                                {    
                                        Line 6 "Windows Advanced Options"    
                                        Line 0 ""    
                                        Line 7 "Setting                                           Enabled  Value                                             "    
                                        Line 7 "============================================================================================================="    
                                        #               123456789012345678901234567890123456789012345678SS1234567SS12345678901234567890123456789012345678901234567890    
                                        #               Remove Common program groups from the start menu  False    SomeConfigFile.xml    
                                        <#    
                                                PartialStartLayoutContent   : Configuration.xml    
                                                Hibernate                   : True    
                                                TeleCollection              : True    
                                                SystemRestore               : True    
                                                AdditionalErrorReport       : True    
                                                Tiles                       : True    
                                                Cortana                     : True    
                                                MicrosoftConsumerExperience : True    
                                                WindowsTips                 : True    
                                                CommonProgramGroups         : True    
                                                PartialStartMenu            : True    
                                        #>    
                                        Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Disable Hibernate", `    
                                        $RDSHost.Optimization.WindowsAdvancedOptions.Hibernate.ToString(), `    
                                        "")    
                                            
                                        Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Disable Telemetry collection", `    
                                        $RDSHost.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(), `    
                                        "")    
                                            
                                        Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Disable System Restore", `    
                                        $RDSHost.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(), `    
                                        "")    
                                            
                                        Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Disable error reporting to send additional data", `    
                                        $RDSHost.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(), `    
                                        "")    
                                            
                                        Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Disable Tiles", `    
                                        $RDSHost.Optimization.WindowsAdvancedOptions.Tiles.ToString(), `    
                                        "")    
                                            
                                        Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Disable Cortana digital assistant", `    
                                        $RDSHost.Optimization.WindowsAdvancedOptions.Cortana.ToString(), `    
                                        "")    
                                            
                                        Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Turn off Microsoft consumer experience", `    
                                        $RDSHost.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(), `    
                                        "")    
                                            
                                        Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Do not show Windows tips", `    
                                        $RDSHost.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(), `    
                                        "")    
                                            
                                        Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Remove Common program groups from the Start Menu", `    
                                        $RDSHost.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(), `    
                                        "")    
                                            
                                        Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Partial Start Menu layout", `    
                                        $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(), `    
                                        $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent)    
                                            
                                        Line 0 ""    
                                }    
     
                                Line 5 "Network performance: " $OPTNetworkPerformanceEnabled    
                                If($OPTNetworkPerformanceEnabled -eq "True")    
                                {    
                                        Line 6 "Network Performance Optimizations"    
                                        Line 0 ""    
                                        Line 7 "Setting                      Enabled  Value"    
                                        Line 7 "==========================================="    
                                        #               123456789012345678901234567SS1234567SS12345    
                                        #               FileNotFoundCacheEntriesMax  False    32768    
                                        <#    
                                                DirCacheMax             : 4096    
                                                DormantFileLimit        : 256    
                                                FileNotFoundCache       : 32768    
                                                FileInfoCache           : 32768    
                                                FileInfoCacheEnable     : True    
                                                DirectoryCacheEnable    : True    
                                                FileNotFoundCacheEnable : True    
                                                DormantFileLimitEnable  : True    
                                                DisableTCP              : True    
                                                DisableIPv6CompEnable   : True    
                                                DisableIPv6ToIPv4       : True    
                                                DisableIsaTap           : True    
                                        #>    
                                        Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "FileInfoCacheEntriesMax", `    
                                        $RDSHost.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(), `    
                                        $RDSHost.Optimization.NetworkPerformance.FileInfoCache)    
                                            
                                        Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "DirectoryCacheEntriesMax", `    
                                        $RDSHost.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(), `    
                                        $RDSHost.Optimization.NetworkPerformance.DirCacheMax)    
                                            
                                        Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "FileNotFoundCacheEntriesMax", `    
                                        $RDSHost.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(), `    
                                        $RDSHost.Optimization.NetworkPerformance.FileNotFoundCache)    
                                            
                                        Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "DormantFileLimit", `    
                                        $RDSHost.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(), `    
                                        $RDSHost.Optimization.NetworkPerformance.DormantFileLimit)    
                                            
                                        Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "Disable TCP/IP Task Offload", `    
                                        $RDSHost.Optimization.NetworkPerformance.DisableTCP.ToString(), `    
                                        "")    
                                            
                                        Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "Disable IPv6 Components", `    
                                        $RDSHost.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(), `    
                                        "")    
                                            
                                        Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "Disable IPv6 to IPv4", `    
                                        $RDSHost.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(), `    
                                        "")    
                                            
                                        Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "Disables isatap for IPv6", `    
                                        $RDSHost.Optimization.NetworkPerformance.DisableIsaTap.ToString(), `    
                                        "")    
                                            
                                        Line 0 ""    
                                }    
     
                                Line 5 "Registry: " $OPTRegistryEnabled    
                                If($OPTRegistryEnabled -eq "True")    
                                {    
                                        Line 6 "Registry Optimizations"    
                                        Line 0 ""    
                                        #               123456789012345678901234567SS1234567SS12345    
                                        #               FileNotFoundCacheEntriesMax  False    32768    
                                        <#    
                                                Id           : 1    
                                                Action       : Modify    
                                                RegistryName : ServicesPipeTimeout    
                                                DWORDValue   : 18000    
                                                DisplayName  : Increase service startup timeouts    
                                                HiveType     : HKEY_LOCAL_MACHINE    
                                                Path         : System\CurrentControlSet\Control    
                                                RegType      : REG_DWORD    
     
                                                Id           : 2    
                                                Action       : Modify    
                                                RegistryName : TimeOutValue    
                                                DWORDValue   : 200    
                                                DisplayName  : Increase Disk I/O Timeout    
                                                HiveType     : HKEY_LOCAL_MACHINE    
                                                Path         : System\CurrentControlSet\Services\Disk    
                                                RegType      : REG_DWORD    
                                        #>    
                                        Line 7 "Registry                                  Action  Value                 Type           Data                  Path                                                        "    
                                        Line 7 "========================================================================================================================================================================="    
                                        #               1234567890123456789012345678901234567890SS123456SS12345678901234567890SS1234567890123SS12345678901234567890SS123456789012345678901234567890123456789012345678901234567890    
                                        #               Increase service startup timeouts         Modify  99999999999999999999  REG_EXPAND_SZ  99999999999999999999  HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Disk    
                                        ForEach($item in $RDSHost.Optimization.Registry.RegistryList)    
                                        {    
                                                If($item.RegType.ToString() -eq "REG_SZ" -or $item.RegType.ToString() -eq "REG_EXPAND_SZ")    
                                                {    
                                                        Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `    
                                                        $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType.ToString(), $item.StringValue, "$($item.HiveType)\$($item.Path)")    
                                                }    
                                                ElseIf($item.RegType.ToString() -eq "REG_DWORD" -or $item.RegType.ToString() -eq "REG_QWORD")    
                                                {    
                                                        Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `    
                                                        $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType.ToString(), $item.DWORDValue, "$($item.HiveType)\$($item.Path)")    
                                                }    
                                                ElseIf($item.RegType.ToString() -eq "REG_MULTI_SZ")    
                                                {    
                                                        #If($item.StringValue.Count -eq 1)    
                                                        #{    
                                                        #       Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `    
                                                        #       $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType.ToString(), $item.StringValue.ToString(), "$($item.HiveType)\$($item.Path)")    
                                                        #}    
                                                        #Else    
                                                        #{    
                                                                $cnt = -1    
                                                                $TmpArray = $item.StringValue.Split("`r")    
                                                                ForEach($SubItem in $TmpArray)    
                                                                {    
                                                                        $cnt++    
                                                                            
                                                                        If($cnt -eq 0)    
                                                                        {    
                                                                                Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `    
                                                                                $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType.ToString(), $SubItem, "$($item.HiveType)\$($item.Path)")    
                                                                        }    
                                                                        Else    
                                                                        {    
                                                                                Line 17 "       " $SubItem    
                                                                        }    
                                                                }    
                                                        #}    
                                                }    
                                        }    
                                        Line 0 ""    
                                }    
     
                                Line 5 "Visual Effects: " $OPTVisualEffectsEnabled    
                                If($OPTVisualEffectsEnabled -eq "True")    
                                {    
                                        Line 6 "Visual Effects Optimizations"    
                                        Line 0 ""    
                                            
                                        Switch ($RDSHost.Optimization.VisualEffects.VisualEffectsTypes)    
                                        {    
                                                "LetWindowsChooseWhatsBest"     {$VisualEffectsType = "Let Windows choose what's best"; Break}    
                                                "AdjustForBestAppearnce"        {$VisualEffectsType = "Adjust for best appearance"; Break} #misspelled in the PoSH output and the docs    
                                                "AdjustForBestPerformance"      {$VisualEffectsType = "Adjust for best performance"; Break}    
                                                "Custom"                                        {$VisualEffectsType = "Custom"; Break}    
                                                Default                                         {$VisualEffectsType = "Unable to determine Visual Effects Optimization type: $($RDSHost.Optimization.VisualEffects.VisualEffectsTypes)"; Break}    
                                        }    
                                        Line 7 $VisualEffectsType    
                                        Line 0 ""    
                                        Line 7 "Setting                                             Enabled"    
                                        Line 7 "==========================================================="    
                                        #               12345678901234567890123456789012345678901234567890SS1234567    
                                        #               Use drop shadows for icon labels on the desktop     False      
                                        <#    
                                                VisualEffectsTypes                     : Custom    
                                                AnimateControlSelectElements           : False    
                                                AnimateWindowsWhenMinimizingMaximizing : False    
                                                AnimateTaskbar                         : False    
                                                EnablePeek                             : False    
                                                FadeSlideMenus                         : False    
                                                FadeSlideToolTips                      : False    
                                                FadeOutMenuItems                       : False    
                                                SaveTaskbarThumbnail                   : False    
                                                ShowShadowUnderMouse                   : False    
                                                ShadowUnderWindows                     : False    
                                                ThumbnailsInsteadOfIcons               : False    
                                                ShowTranslucentSelection               : False    
                                                ShowWindowsContentWhilstDragging       : False    
                                                SlideOpenComboBoxes                    : False    
                                                SmoothEdgesScreenFonts                 : True    
                                                SmoothScrollListBoxes                  : False    
                                                DropShadowsIcon                        : False    
                                        #>    
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Animate controls and elements inside windows", `    
                                        $RDSHost.Optimization.VisualEffects.AnimateControlSelectElements.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Animate windows when minimizing and maximizing", `    
                                        $RDSHost.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Animations in the taskbar", `    
                                        $RDSHost.Optimization.VisualEffects.AnimateTaskbar.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Enable Peek", `    
                                        $RDSHost.Optimization.VisualEffects.EnablePeek.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Fade or slide menus into view", `    
                                        $RDSHost.Optimization.VisualEffects.FadeSlideMenus.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Fade or slide Tooltips into view", `    
                                        $RDSHost.Optimization.VisualEffects.FadeSlideToolTips.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Fade out menu items after clicking", `    
                                        $RDSHost.Optimization.VisualEffects.FadeOutMenuItems.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Save taskbar thumbnail previews", `    
                                        $RDSHost.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Show shadows under mouse pointer", `    
                                        $RDSHost.Optimization.VisualEffects.ShowShadowUnderMouse.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Show shadows under windows", `    
                                        $RDSHost.Optimization.VisualEffects.ShadowUnderWindows.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Show thumbnails instead of icons", `    
                                        $RDSHost.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Show translucent selection rectangle", `    
                                        $RDSHost.Optimization.VisualEffects.ShowTranslucentSelection.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Show window contents while dragging", `    
                                        $RDSHost.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Slide open combo boxes", `    
                                        $RDSHost.Optimization.VisualEffects.SlideOpenComboBoxes.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Smooth edges of screen fonts", `    
                                        $RDSHost.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Smooth-scroll list boxes", `    
                                        $RDSHost.Optimization.VisualEffects.SmoothScrollListBoxes.ToString())    
                                            
                                        Line 7 ( "{0,-50}  {1,-7}" -f `    
                                        "Use drop shadows for icon labels on the desktop", `    
                                        $RDSHost.Optimization.VisualEffects.DropShadowsIcon.ToString())    
                                            
                                        Line 0 ""    
                                }    
     
                                Line 5 "Disk cleanup: " $OPTDiskCleanupEnabled    
                                If($OPTDiskCleanupEnabled -eq "True")    
                                {    
                                        Line 6 "Disk Cleanup Optimizations"    
                                        Line 0 ""    
                                            
                                        Line 7 "Setting                            Enabled"    
                                        Line 7 "=========================================="    
                                        #               123456789012345678901234567890123SS1234567    
                                        #               Clean up temporary files and logs  False      
                                        <#    
                                                CleanupWinSxSFolder      : False    
                                                CleanupSystemFiles       : False    
                                                CleanupTemporaryFileLogs : True    
                                                RemoveOneDrive           : False    
                                                DeleteUserProfiles       : False    
                                        #>    
                                        Line 7 ( "{0,-33}  {1,-7}" -f `    
                                        "Clean up redundant system files", `    
                                        $RDSHost.Optimization.DiskCleanup.CleanupSystemFiles.ToString())    
                                            
                                        Line 7 ( "{0,-33}  {1,-7}" -f `    
                                        "Clean up the WinSxS Folder", `    
                                        $RDSHost.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString())    
                                            
                                        Line 7 ( "{0,-33}  {1,-7}" -f `    
                                        "Clean up temporary files and logs", `    
                                        $RDSHost.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString())    
                                            
                                        Line 7 ( "{0,-33}  {1,-7}" -f `    
                                        "Remove OneDrive", `    
                                        $RDSHost.Optimization.DiskCleanup.RemoveOneDrive.ToString())    
                                            
                                        Line 7 ( "{0,-33}  {1,-7}" -f `    
                                        "Delete users' profiles", `    
                                        $RDSHost.Optimization.DiskCleanup.DeleteUserProfiles.ToString())    
                                            
                                        Line 0 ""    
                                }    
     
                                Line 5 "Custom script: " $OPTCustomScriptEnabled    
                                If($OPTCustomScriptEnabled  -eq "True")    
                                {    
                                        Line 6 "Custom Script"    
                                        Line 0 ""    
                                            
                                        <#    
                                                Arguments : CustomScriptArguments    
                                                Command   : CustomScriptCommand    
                                                InitDir   : CustomScriptInitialDirectory    
                                                User      : CustomScriptUsername    
                                        #>    
                                        Line 7 "Command`t`t : " $RDSHost.Optimization.CustomScript.Command    
                                        Line 7 "Arguments`t : " $RDSHost.Optimization.CustomScript.Arguments    
                                        Line 7 "Initial directory: " $RDSHost.Optimization.CustomScript.InitDir    
                                        Line 7 "Username`t : " $RDSHost.Optimization.CustomScript.User    
                                        Line 0 ""    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings:",($Script:htmlsb),$RDSHost.InheritDefaultOptimizationSettings.ToString(),$htmlwhite)    
                                $rowdata += @(,("Enable optimization",($Script:htmlsb), $OPTEnableOptimization,$htmlwhite))    
                                $rowdata += @(,("Optimization type",($Script:htmlsb), $OPTOptimizationType,$htmlwhite))    
     
                                $msg = "Optimization"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 4 0 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled    
                                If($OPTWindowsDefenderATPEnabled -eq "True")    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Windows Defender ATP Optimizations",($Script:htmlsb),"",$htmlwhite)    
     
                                        If($RDSHost.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")    
                                        {    
                                                $rowdata += @(,("     Turn off Windows Defender ATP (I use my own ATP solution)",($Script:htmlsb), "",$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("     Turn on Windows Defender ATP and set process and folder exclusions",($Script:htmlsb), "",$htmlwhite))    
                                                $rowdata += @(,("     Disable real-time protection",($Script:htmlsb), $RDSHost.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(),$htmlwhite))    
                                                $rowdata += @(,("",($Script:htmlsb), "",$htmlwhite))    
                                                    
                                                $cnt = -1    
                                                ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeFolders)    
                                                {    
                                                        $cnt++    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $rowdata += @(,("     Exclude files and folders",($Script:htmlsb), $item,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))    
                                                        }    
                                                }    
     
                                                $cnt = -1    
                                                ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeProcesses)    
                                                {    
                                                        $cnt++    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $rowdata += @(,("     Exclude processes",($Script:htmlsb), $item,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))    
                                                        }    
                                                }    
                                                    
                                                $cnt = -1    
                                                ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeExtension)    
                                                {    
                                                        $cnt++    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $rowdata += @(,("     Exclude extensions",($Script:htmlsb), $item,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))    
                                                        }    
                                                }    
                                        }    
     
     
                                        $msg = ""    
                                        $columnWidths = @("300","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Windows Components: " $OPTWindowsComponentsEnabled    
                                If($OPTWindowsComponentsEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Windows Components Optimizations"    
     
                                        $rowdata = @()    
     
                                        ForEach($item in $RDSHost.Optimization.WindowsComponents.WindowsComponentsList)    
                                        {    
                                                $rowdata += @(,(    
                                                        $item.DisplayName,$htmlwhite,    
                                                        $item.ComponentName,$htmlwhite)    
                                                )    
                                        }    
     
                                        $columnHeaders = @(    
                                                "Display Name",($Script:htmlsb),    
                                                "Component",($Script:htmlsb)    
                                        )    
     
                                        $msg = "Disable (remove) components:"    
                                        $columnWidths = @("200","200")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Windows Services: " $OPTWindowsServicesEnabled           
                                If($OPTWindowsServicesEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Windows Services Optimizations"    
     
                                        $rowdata = @()    
     
                                        ForEach($item in $RDSHost.Optimization.WindowsServices.WindowsServicesList)    
                                        {    
                                                $rowdata += @(,(    
                                                        $item.DisplayName,$htmlwhite,    
                                                        $item.ServiceName,$htmlwhite,    
                                                        $item.Aliases,$htmlwhite)    
                                                )    
                                        }    
     
                                        $columnHeaders = @(    
                                                "Display Name",($Script:htmlsb),    
                                                "Service",($Script:htmlsb),    
                                                "Aliases",($Script:htmlsb)    
                                        )    
     
                                        $msg = "Disable services:"    
                                        $columnWidths = @("200","100","50")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled    
                                If($OPTWinodwsScheduledTasksEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Windows Scheduled Tasks Optimizations"    
     
                                        $rowdata = @()    
     
                                        ForEach($item in $RDSHost.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)    
                                        {    
                                                $rowdata += @(,(    
                                                        $item.Task,$htmlwhite,    
                                                        $item.Type.Tostring(),$htmlwhite,    
                                                        $item.Location,$htmlwhite)    
                                                )    
                                        }    
     
                                        $columnHeaders = @(    
                                                "Task",($Script:htmlsb),    
                                                "Type",($Script:htmlsb),    
                                                "Location",($Script:htmlsb)    
                                        )    
     
                                        $msg = "Disable tasks:"    
                                        $columnWidths = @("200","50","250")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled    
                                If($OPTWindowsAdvancedOptionsEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Windows Advanced Options"    
     
                                        $rowdata = @()    
     
                                        $rowdata += @(,(    
                                                "Disable Hibernate",$htmlwhite,    
                                                $RDSHost.Optimization.WindowsAdvancedOptions.Hibernate.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable Telemetry collection",$htmlwhite,    
                                                $RDSHost.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable System Restore",$htmlwhite,    
                                                $RDSHost.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable error reporting to send additional data",$htmlwhite,    
                                                $RDSHost.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable Tiles",$htmlwhite,    
                                                $RDSHost.Optimization.WindowsAdvancedOptions.Tiles.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable Cortana digital assistant",$htmlwhite,    
                                                $RDSHost.Optimization.WindowsAdvancedOptions.Cortana.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Turn off Microsoft consumer experience",$htmlwhite,    
                                                $RDSHost.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Do not show Windows tips",$htmlwhite,    
                                                $RDSHost.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Remove Common program groups from the Start Menu",$htmlwhite,    
                                                $RDSHost.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Partial Start Menu layout",$htmlwhite,    
                                                $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(),$htmlwhite,    
                                                $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent,$htmlwhite)    
                                        )    
     
                                        $columnHeaders = @(    
                                                "Setting",($Script:htmlsb),    
                                                "Enabled",($Script:htmlsb),    
                                                "Value",($Script:htmlsb)    
                                        )    
     
                                        $msg = ""    
                                        $columnWidths = @("300","50","200")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Network performance: " $OPTNetworkPerformanceEnabled    
                                If($OPTWindowsAdvancedOptionsEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Network Performance Optimizations"    
     
                                        $rowdata = @()    
     
                                        $rowdata += @(,(    
                                                "FileInfoCacheEntriesMax",$htmlwhite,    
                                                $RDSHost.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(),$htmlwhite,    
                                                $RDSHost.Optimization.NetworkPerformance.FileInfoCache,$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "DirectoryCacheEntriesMax",$htmlwhite,    
                                                $RDSHost.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(),$htmlwhite,    
                                                $RDSHost.Optimization.NetworkPerformance.DirCacheMax,$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "FileNotFoundCacheEntriesMax",$htmlwhite,    
                                                $RDSHost.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(),$htmlwhite,    
                                                $RDSHost.Optimization.NetworkPerformance.FileNotFoundCache,$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "DormantFileLimit",$htmlwhite,    
                                                $RDSHost.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(),$htmlwhite,    
                                                $RDSHost.Optimization.NetworkPerformance.DormantFileLimit,$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable TCP/IP Task Offload",$htmlwhite,    
                                                $RDSHost.Optimization.NetworkPerformance.DisableTCP.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable IPv6 Components",$htmlwhite,    
                                                $RDSHost.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable IPv6 to IPv4",$htmlwhite,    
                                                $RDSHost.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disables isatap for IPv6",$htmlwhite,    
                                                $RDSHost.Optimization.NetworkPerformance.DisableIsaTap.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $columnHeaders = @(    
                                                "Setting",($Script:htmlsb),    
                                                "Enabled",($Script:htmlsb),    
                                                "Value",($Script:htmlsb)    
                                        )    
     
                                        $msg = ""    
                                        $columnWidths = @("170","50","50")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Registry: " $OPTRegistryEnabled           
                                If($OPTRegistryEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Registry Optimizations"    
     
                                        $rowdata = @()    
     
                                        ForEach($item in $RDSHost.Optimization.Registry.RegistryList)    
                                        {    
                                                If($item.RegType.ToString() -eq "REG_SZ" -or $item.RegType.ToString() -eq "REG_EXPAND_SZ")    
                                                {    
                                                        $rowdata += @(,(    
                                                                $item.DisplayName,$htmlwhite,    
                                                                $item.Action,$htmlwhite,    
                                                                $item.RegistryName,$htmlwhite,    
                                                                $item.RegType.ToString(),$htmlwhite,    
                                                                $item.StringValue,$htmlwhite,    
                                                                "$($item.HiveType)\$($item.Path)",$htmlwhite)    
                                                        )    
                                                }    
                                                ElseIf($item.RegType.ToString() -eq "REG_DWORD" -or $item.RegType.ToString() -eq "REG_QWORD")    
                                                {    
                                                        $rowdata += @(,(    
                                                                $item.DisplayName,$htmlwhite,    
                                                                $item.Action,$htmlwhite,    
                                                                $item.RegistryName,$htmlwhite,    
                                                                $item.RegType.ToString(),$htmlwhite,    
                                                                $item.DWORDValue,$htmlwhite,    
                                                                "$($item.HiveType)\$($item.Path)",$htmlwhite)    
                                                        )    
                                                }    
                                                ElseIf($item.RegType.ToString() -eq "REG_MULTI_SZ")    
                                                {    
                                                        $rowdata += @(,(    
                                                                $item.DisplayName,$htmlwhite,    
                                                                $item.Action,$htmlwhite,    
                                                                $item.RegistryName,$htmlwhite,    
                                                                $item.RegType.ToString(),$htmlwhite,    
                                                                $item.StringValue.ToString(),$htmlwhite,    
                                                                "$($item.HiveType)\$($item.Path)",$htmlwhite)    
                                                        )    
                                                }    
                                        }    
     
                                        $columnHeaders = @(    
                                                "Registry",($Script:htmlsb),    
                                                "Action",($Script:htmlsb),    
                                                "Value",($Script:htmlsb),    
                                                "Type",($Script:htmlsb),    
                                                "Data",($Script:htmlsb),    
                                                "Path",($Script:htmlsb)    
                                        )    
     
                                        $msg = ""    
                                        $columnWidths = @("200","50","100","100","100","200")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Visual Effects: " $OPTVisualEffectsEnabled    
                                If($OPTVisualEffectsEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Visual Effects Optimizations"    
     
                                        $rowdata = @()    
     
                                        $rowdata += @(,(    
                                                "Animate controls and elements inside windows",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.AnimateControlSelectElements.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Animate windows when minimizing and maximizing",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Animations in the taskbar",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.AnimateTaskbar.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Enable Peek",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.EnablePeek.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Fade or slide menus into view",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.FadeSlideMenus.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Fade or slide Tooltips into view",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.FadeSlideToolTips.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Fade out menu items after clicking",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.FadeOutMenuItems.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Save taskbar thumbnail previews",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Show shadows under mouse pointer",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.ShowShadowUnderMouse.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Show shadows under windows",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.ShadowUnderWindows.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Show thumbnails instead of icons",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Show translucent selection rectangle",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.ShowTranslucentSelection.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Show window contents while dragging",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Slide open combo boxes",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.SlideOpenComboBoxes.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Smooth edges of screen fonts",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Smooth-scroll list boxes",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.SmoothScrollListBoxes.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Use drop shadows for icon labels on the desktop",$htmlwhite,    
                                                $RDSHost.Optimization.VisualEffects.DropShadowsIcon.ToString(),$htmlwhite)    
                                        )    
     
                                        $columnHeaders = @(    
                                                "Setting",($Script:htmlsb),    
                                                "Enabled",($Script:htmlsb)    
                                        )    
     
                                        $msg = ""    
                                        $columnWidths = @("275","50")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Disk cleanup: " $OPTDiskCleanupEnabled    
                                If($OPTDiskCleanupEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Disk Cleanup Optimizations"    
     
                                        $rowdata = @()    
     
                                        $rowdata += @(,(    
                                                "Clean up redundant system files",$htmlwhite,    
                                                $RDSHost.Optimization.DiskCleanup.CleanupSystemFiles.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Clean up the WinSxS Folder",$htmlwhite,    
                                                $RDSHost.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Clean up temporary files and logs",$htmlwhite,    
                                                $RDSHost.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Remove OneDrive",$htmlwhite,    
                                                $RDSHost.Optimization.DiskCleanup.RemoveOneDrive.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Delete users' profiles",$htmlwhite,    
                                                $RDSHost.Optimization.DiskCleanup.DeleteUserProfiles.ToString(),$htmlwhite)    
                                        )    
     
                                        $columnHeaders = @(    
                                                "Setting",($Script:htmlsb),    
                                                "Enabled",($Script:htmlsb)    
                                        )    
     
                                        $msg = ""    
                                        $columnWidths = @("200","50")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Custom script: " $OPTCustomScriptEnabled    
                                If($OPTCustomScriptEnabled -eq "True")    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Custom Script",($Script:htmlsb),"",$htmlwhite)    
                                        $rowdata += @(,("     Command",($Script:htmlsb), $RDSHost.Optimization.CustomScript.Command,$htmlwhite))    
                                        $rowdata += @(,("     Arguments",($Script:htmlsb), $RDSHost.Optimization.CustomScript.Arguments,$htmlwhite))    
                                        $rowdata += @(,("     Initial directory",($Script:htmlsb), $RDSHost.Optimization.CustomScript.InitDir,$htmlwhite))    
                                        $rowdata += @(,("     Username",($Script:htmlsb), $RDSHost.Optimization.CustomScript.User,$htmlwhite))    
     
                                        $msg = ""    
                                        $columnWidths = @("125","200")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                        }    
     
                        #Desktop Access    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Desktop access"    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Desktop access"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($RDSHost.InheritDefaultDesktopAccessSettings)    
                        {    
                                #do we inherit group or site defaults?    
                                #is this RDS host in a group?    
                                #http://woshub.com/hot-to-convert-sid-to-username-and-vice-versa/    
                                #for translating the User SID to the AD user name    
                                $Results = Get-RASRDSGroup -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $Results)    
                                {    
                                        If($Results.RDSIds -Contains $RDSHost.Id )    
                                        {    
                                                #does this group inherit default settings?    
                                                If($Results.InheritDefaultDesktopAccessSettings -eq $False)    
                                                {    
                                                        #no we don't, so get the default settings for the group    
                                                        $GroupDefaults = $Results.RDSDefSettings    
     
                                                        $RDSRestrictDesktopAccess = $GroupDefaults.RestrictDesktopAccess.ToString()    
                                                        $RDSRestrictedUsers       = @()    
                                                            
                                                        ForEach($User in $GroupDefaults.RestrictedUsers)    
                                                        {    
                                                                $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)    
                                                                $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])    
                                                                    
                                                                $RDSRestrictedUsers += $objUser.Value    
                                                        }    
                                                }    
                                                Else    
                                                {    
                                                        #yes we do, get the default settings for the Site    
                                                        #use the Site default settings    
                                                        $RDSDefaults = Get-RASRDSDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                                            
                                                        If($? -and $Null -ne $RDSDefaults)    
                                                        {    
                                                                $RDSRestrictDesktopAccess = $RDSDefaults.RestrictDesktopAccess.ToString()    
                                                                $RDSRestrictedUsers       = @()    
                                                                    
                                                                ForEach($User in $RDSDefaults.RestrictedUsers)    
                                                                {    
                                                                        $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)    
                                                                        $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])    
                                                                            
                                                                        $RDSRestrictedUsers += $objUser.Value    
                                                                }    
                                                        }    
                                                        Else    
                                                        {    
                                                                #unable to retrieve default, use built-in default values    
                                                                $RDSRestrictDesktopAccess = "False"    
                                                                $RDSRestrictedUsers       = @()    
                                                        }    
                                                }    
                                        }    
                                }    
                                Else    
                                {    
                                        #RDS Host is not in a group    
                                        #get the settings for the host    
                                        $RDSRestrictDesktopAccess = $RDSHost.RestrictDesktopAccess.ToString()    
                                        $RDSRestrictedUsers       = @()    
                                            
                                        ForEach($User in $RDSHost.RestrictedUsers)    
                                        {    
                                                $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)    
                                                $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])    
                                                    
                                                $RDSRestrictedUsers += $objUser.Value    
                                        }    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit    
                                #get the settings for the host    
                                $RDSRestrictDesktopAccess = $RDSHost.RestrictDesktopAccess.ToString()    
                                $RDSRestrictedUsers       = @()    
                                    
                                ForEach($User in $RDSHost.RestrictedUsers)    
                                {    
                                        $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)    
                                        $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])    
                                            
                                        $RDSRestrictedUsers += $objUser.Value    
                                }    
                        }    
                                    
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $RDSHost.InheritDefaultDesktopAccessSettings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Restrict direct desktop access to the following users"; Value = $RDSRestrictDesktopAccess; }) > $Null    
                                    
                                $cnt = -1    
                                ForEach($Item in $RDSRestrictedUsers)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Users"; Value = $Item; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 250;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
 
                                                        $RDSRemoveClientNameFromPrinter          = $GroupDefaults.RemoveClientNameFromPrinterName.ToString() +-  
 
                                                                $RDSRemoveClientNameFromPrinter          = $RDSDefaults.RemoveClientNameFromPrinterName.ToString() +-  
 
                                                                $RDSRemoveClientNameFromPrinter          = "False" +-  
 
                                        $RDSRemoveClientNameFromPrinter          = $RDSHost.RemoveClientNameFromPrinterName.ToString() +-  
 
                                $RDSRemoveClientNameFromPrinter    = $RDSHost.RemoveClientNameFromPrinterName.ToString() +-  
 
                                If($RDSHost.RemoveSessionNumberFromPrinterName) +-  
                                {    
                                        $ScriptInformation.Add(@{Data = "Remove client name from printer name"; Value = $RDSRemoveClientNameFromPrinter; }) > $Null    
                                }    
 
                                If($RDSHost.RemoveSessionNumberFromPrinterName) +-  
                                {    
                                        Line 4 "Remove client name from printer name`t`t`t: " $RDSRemoveClientNameFromPrinter    
                                }    
 
                                If($RDSHost.RemoveSessionNumberFromPrinterName) +-  
                                {    
                                        $rowdata += @(,("Remove client name from printer name",($Script:htmlsb),$RDSRemoveClientNameFromPrinter,$htmlwhite))    
                                }    
 
        Write-Verbose "$(Get-Date -Format G): `tOutput RD Session Hosts Groups" <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Host Groups"
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Groups"    
        }    
        If($Text)    
        {    
                Line 1 "Groups"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Groups"    
        }    
     
 
        No RD Session Host Groups retrieved for Site $($Site.Name).` <>                 No RD Session Host Groups retrieved for Site $($Site.Name).`
 
                ForEach($RDSGroup in $RDSGroups) <>                 If($MSWord -or $PDF)
 
                        #Get the agent state for the group <>                         WriteWordLine 2 0 "Groups"
                        $RDSGroupStatus = Get-RASRDSGroupStatus -Name $RDSGroup.Name -EA 0 4>$Null    
                                           }
                        If(!$? -or $Null -eq $RDSGroupStatus)                   If($Text)
                        {                   {
                                $RDSGroupAgentState = "Unknown"                           Line 1 "Groups"
                        }                   }
                        Else                   If($HTML)
                        {                   {
                                $RDSGroupAgentState = GetRASStatus $RDSGroupStatus.AgentState                           WriteHTMLLine 2 0 "Groups"
                        }                   }
                            
                    ForEach($RDSGroup in $RDSGroups)
                    {
                            Write-Verbose "$(Get-Date -Format G): `t`t`tOutput RD Session Host Group $($RDSGroup.Name)"
 
                                $ScriptInformation.Add(@{Data = "Status"; Value = $RDSGroupAgentState; }) > $Null +-  
 
                                Line 2 "Status`t`t`t: " $RDSGroupAgentState +-  
 
                                $rowdata += @(,("Status",($Script:htmlsb),$RDSGroupAgentState,$htmlwhite)) +-  
 
  <>  
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 250;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                   $ScriptInformation.Add(@{Data = "RD session hosts based on a template"; Value = $RDSGroup.UseRASTemplate; }) > $Null
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Enable Group in site`t: " $RDSGroup.Enabled.ToString()    
                                Line 3 "Name`t`t`t: " $RDSGroup.Name    
                                Line 3 "Description`t`t: " $RDSGroup.Description    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Enable Group in site",($Script:htmlsb),$RDSGroup.Enabled.ToString(),$htmlwhite)                                   $ScriptInformation.Add(@{Data = "RAS template"; Value = $RDSGroup.RASTemplateId; }) > $Null
                                $rowdata += @(,("Name",($Script:htmlsb),$RDSGroup.Name,$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$RDSGroup.Description,$htmlwhite))    
     
                                $msg = "General"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Servers    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Servers"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Servers"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
 
  -+                                         $ScriptInformation.Add(@{Data = "Group Members"; Value = ""; }) > $Null
 
                                                If($RDSGroupMember.Enabled) <>  
                                                {    
                                                        $RDSGroupMemberLogonStatus = "Enabled"    
                                                }    
                                                Else    
                                                {    
                                                        $RDSGroupMemberLogonStatus = "Disabled"    
                                                }    
                                                    
                                                $Status = Get-RASRDSStatus -Server $RDSGroupMember.Server  -EA 0 4>$Null    
                                                    
                                                If($? -and $Null -ne $Status)    
                                                {    
                                                        $AgentStatus = GetRASStatus $Status.AgentState    
                                                        $cnt++                                                   $cnt++
                                                        $ScriptInformation.Add(@{Data = "Server"; Value = $RDSGroupMember.Server; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Member"; Value = $RDSGroupMember.Server; }) > $Null
                                                        $ScriptInformation.Add(@{Data = "Status"; Value = $AgentStatus; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Logon status"; Value = $RDSGroupMember.Enabled.ToString(); }) > $Null
                                                        $ScriptInformation.Add(@{Data = "Logon status"; Value = $RDSGroupMemberLogonStatus; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Type"; Value = "Server"; }) > $Null
                                                        $ScriptInformation.Add(@{Data = "Description"; Value = $RDSGroupMember.Description; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Description"; Value = $RDSGroupMember.Description; }) > $Null
                                                        $ScriptInformation.Add(@{Data = "Sessions"; Value = $Status.ActiveSessions.ToString(); }) > $Null    
                                                        If($RDSGroupMembers.Count -gt 1)                                                   If($RDSGroupMembers.Count -gt 1)
                                                        {                                                   {
                                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null                                                           $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                        }    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "Server"; Value = "Error retrieving server $($RDSGroupMember.Server) status"; }) > $Null    
 
  -+                                 Line 3 "Enable Group in site`t`t`t: " $RDSGroup.Enabled.ToString()
                                    Line 3 "Name`t`t`t`t`t: " $RDSGroup.Name
                                    Line 3 "Description`t`t`t`t: " $RDSGroup.Description
                                    Line 3 "RD session hosts based on a template`t: " $RDSGroup.UseRASTemplate
                                    Line 3 "RAS template`t`t`t`t: " $RDSGroup.RASTemplateId
 
  -+                                         Line 3 "Group Members" ""
 
                                                If($RDSGroupMember.Enabled) <>  
                                                {    
                                                        $RDSGroupMemberLogonStatus = "Enabled"    
                                                }    
                                                Else    
                                                {    
                                                        $RDSGroupMemberLogonStatus = "Disabled"    
                                                }    
                                                            
                                                $Status = Get-RASRDSStatus -Server $RDSGroupMember.Server  -EA 0 4>$Null    
                                                            
                                                If($? -and $Null -ne $Status)    
                                                {    
                                                        $AgentStatus = GetRASStatus $Status.AgentState    
                                                        $cnt++                                                   $cnt++
                                                        Line 3 "Server`t`t: " $RDSGroupMember.Server                                                   Line 4 "Member`t`t: " $RDSGroupMember.Server
                                                        Line 3 "Status`t`t: " $AgentStatus    
                                                        Line 3 "Logon status`t: " $RDSGroupMemberLogonStatus                                                   Line 4 "Logon status`t: " $RDSGroupMember.Enabled.ToString()
                                                    Line 4 "Type`t`t: " "Server"
                                                        Line 3 "Description`t: " $RDSGroupMember.Description                                                   Line 4 "Description`t: " $RDSGroupMember.Description
                                                        Line 3 "Sessions`t: " $Status.ActiveSessions.ToString()    
                                                        If($RDSGroupMembers.Count -gt 1)                                                   If($RDSGroupMembers.Count -gt 1)
                                                        {                                                   {
                                                                Line 3 ""                                                           Line 4 ""
                                                        }    
                                                }    
                                                Else    
                                                {    
                                                        Line 3 "Server`t`t: " "Error retrieving server $($RDSGroupMember.Server) status"    
 
  -+                                 $columnHeaders = @("Enable Group in site",($Script:htmlsb),$RDSGroup.Enabled.ToString(),$htmlwhite)
                                    $rowdata += @(,("Name",($Script:htmlsb),$RDSGroup.Name,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$RDSGroup.Description,$htmlwhite))
                                    $rowdata += @(,("RD session hosts based on a template",($Script:htmlsb),$RDSGroup.UseRASTemplate.ToString(),$htmlwhite))
                                    $rowdata += @(,("RAS template",($Script:htmlsb),$RDSGroup.RASTemplateId.ToString(),$htmlwhite))
 
  -+                                         $rowdata += @(,("Group Members",($Script:htmlsb),"",$htmlwhite))
 
                                                If($RDSGroupMember.Enabled) <>  
                                                {    
                                                        $RDSGroupMemberLogonStatus = "Enabled"    
                                                }    
                                                Else    
                                                {    
                                                        $RDSGroupMemberLogonStatus = "Disabled"    
                                                }    
                                                            
                                                $Status = Get-RASRDSStatus -Server $RDSGroupMember.Server  -EA 0 4>$Null    
                                                    
                                                If($? -and $Null -ne $Status)    
                                                {    
                                                        $AgentStatus = GetRASStatus $Status.AgentState    
                                                        $cnt++                                                   $cnt++
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $columnHeaders = @("Member",($Script:htmlsb),$RDSGroupMember.Server,$htmlwhite)    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("Member",($Script:htmlsb),$RDSGroupMember.Server,$htmlwhite))                                                   $rowdata += @(,("     Member",($Script:htmlsb),$RDSGroupMember.Server,$htmlwhite))
                                                        }    
                                                        $rowdata += @(,("Status",($Script:htmlsb),$AgentStatus,$htmlwhite))                                                   $rowdata += @(,("     Logon status",($Script:htmlsb),$RDSGroupMember.Enabled.ToString(),$htmlwhite))
                                                        $rowdata += @(,("Logon status",($Script:htmlsb),$RDSGroupMemberLogonStatus,$htmlwhite))                                                   $rowdata += @(,("     Type",($Script:htmlsb),"Server",$htmlwhite))
                                                        $rowdata += @(,("Description",($Script:htmlsb),$RDSGroupMember.Description,$htmlwhite))                                                   $rowdata += @(,("     Description",($Script:htmlsb),$RDSGroupMember.Description,$htmlwhite))
                                                        $rowdata += @(,("Sessions",($Script:htmlsb),$Status.ActiveSessions.ToString(),$htmlwhite))    
                                                        If($RDSGroupMembers.Count -gt 1)                                                   If($RDSGroupMembers.Count -gt 1)
                                                        {                                                   {
                                                                $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                                           $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                                        }    
 
                                                Else +-  
                                                {    
                                                        $rowdata += @(,("Server",($Script:htmlsb),"Error retrieving server $($RDSGroupMember.Server) status",$htmlwhite))    
                                                }    
 
                                $msg = "Servers" <>                                 $msg = "General"
 
                                                "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; <>                                                 "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break}
                                                                                                                 $ReplaceRegisteredApplication = "False";    
                                                                                                                 Break}    
                                                "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";                                                   "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}
                                                                                                                 $ReplaceRegisteredApplication = "False";    
                                                                                                                 Break}    
                                                "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";                                                   "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}
                                                                                                                 $ReplaceRegisteredApplication = "True";    
                                                                                                                 Break}    
                                                Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSDefaults.AllowURLAndMailRedirection)";                                                   Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSDefaults.AllowURLAndMailRedirection)"; Break}
                                                                                                                 $ReplaceRegisteredApplication = "False";    
                                                                                                                 Break}    
 
                                                "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; <>                                                 "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break}
                                                $RDSAllowDragAndDrop = "True";    
                                                Break}    
                                                "Disabled"                      {$RDSDragAndDrop = "Disabled";                                                   "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}
                                                $RDSAllowDragAndDrop = "False";    
                                                Break}    
                                                "ClientToServer"        {$RDSDragAndDrop = "Client to server only";                                                   "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}
                                                $RDSAllowDragAndDrop = "True";    
                                                Break}    
                                                "ServerToClient"        {$RDSDragAndDrop = "Server to client only";                                                   "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}
                                                $RDSAllowDragAndDrop = "True";    
                                                Break}    
                                                Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSDefaults.DragAndDropMode)";                                                   Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSDefaults.DragAndDropMode)"; Break}
                                                $RDSAllowDragAndDrop = "False";    
                                                Break}    
 
                                        If($RDSDefaults.PreferredBrokerId -eq 0) <>                                         If($RDSDefaults.PreferredPAId -eq 0)
 
                                                $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSDefaults.PreferredBrokerId -EA 0 4>$Null).Server <>                                                 $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSDefaults.PreferredPAId -EA 0 4>$Null).Server
 
                                        $ReplaceRegisteredApplication          = "False" +-  
 
                                        $RDSAllowDragAndDrop                   = "True" +-  
 
                                        "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; <>                                         "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break}
                                                                                                         $ReplaceRegisteredApplication = "False";    
                                                                                                         Break}    
                                        "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";                                           "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}
                                                                                                         $ReplaceRegisteredApplication = "False";    
                                                                                                         Break}    
                                        "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";                                           "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}
                                                                                                         $ReplaceRegisteredApplication = "True";    
                                                                                                         Break}    
                                        Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSGroupDefaults.AllowURLAndMailRedirection)";                                           Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSGroup.AllowURLAndMailRedirection)"; Break}
                                                                                                         $ReplaceRegisteredApplication = "False";    
                                                                                                         Break}    
 
                                        "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; <>                                         "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break}
                                        $RDSAllowDragAndDrop = "True";    
                                        Break}    
                                        "Disabled"                      {$RDSDragAndDrop = "Disabled";                                           "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}
                                        $RDSAllowDragAndDrop = "False";    
                                        Break}    
                                        "ClientToServer"        {$RDSDragAndDrop = "Client to server only";                                           "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}
                                        $RDSAllowDragAndDrop = "True";    
                                        Break}    
                                        "ServerToClient"        {$RDSDragAndDrop = "Server to client only";                                           "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}
                                        $RDSAllowDragAndDrop = "True";    
                                        Break}    
                                        Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSGroupDefaults.DragAndDropMode)";                                           Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSGroup.DragAndDropMode)"; Break}
                                        $RDSAllowDragAndDrop = "False";    
                                        Break}    
 
                                If($RDSGroupDefaults.PreferredBrokerId -eq 0) <>                                 If($RDSGroupDefaults.PreferredPAId -eq 0)
 
                                        $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSGroupDefaults.PreferredBrokerId -EA 0 4>$Null).Server <>                                         $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSGroupDefaults.PreferredPAId -EA 0 4>$Null).Server
 
                                $ScriptInformation.Add(@{Data = "Application session lingering"; Value = ""; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "     Disconnect active session after"; Value = $RDSPublishingSessionDisconnectTimeout; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Logoff disconnected session after"; Value = $RDSPublishingSessionResetTime; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Other settings"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Port"; Value = $RDSPort; }) > $Null                                   $ScriptInformation.Add(@{Data = "Port"; Value = $RDSPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Max Sessions"; Value = $RDSMaxSessions; }) > $Null                                   $ScriptInformation.Add(@{Data = "Max Sessions"; Value = $RDSMaxSessions; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Publishing Session Disconnect Timeout"; Value = $RDSPublishingSessionDisconnectTimeout; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Preferred Connection Broker"; Value = $RDSPreferredPublishingAgent; }) > $Null                                   $ScriptInformation.Add(@{Data = "Publishing Session Reset Timeout"; Value = $RDSPublishingSessionResetTime; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "     Replace registered application"; Value = $ReplaceRegisteredApplication; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "     Support Windows Shell URL namespace objects"; Value = $RDSSupportShellURLNamespaceObject; }) > $Null                                   $ScriptInformation.Add(@{Data = "Support Windows Shell URL namespace objects"; Value = $RDSSupportShellURLNamespaceObject; }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable Drag and drop"; Value = $RDSAllowDragandDrop; }) > $Null                                   $ScriptInformation.Add(@{Data = "Drag and drop"; Value = $RDSDragAndDrop; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Direction"; Value = $RDSDragAndDrop; }) > $Null                                   $ScriptInformation.Add(@{Data = "Preferred Publishing Agent"; Value = $RDSPreferredPublishingAgent; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Allow file transfer command (Web (HTML5) and Chrome clients)"; Value = $RDSAllowFileTransfer; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Allow file transfer command (HTML5 and Chrome clients)"; Value = $RDSAllowFileTransfer; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Configure File Transfer"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Configure File Transfer"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Direction"; Value = $RDSFileTransferMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Direction"; Value = $RDSFileTransferMode; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Location"; Value = $RDSFileTransferLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Location"; Value = $RDSFileTransferLocation; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Do not allow to change location"; Value = $RDSFileTransferChangeLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Do not allow to change location"; Value = $RDSFileTransferChangeLocation; }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable drive redirection cache"; Value = $RDSEnableDriveRedirectionCache; }) > $Null    
 
                                Line 3 "Inherit default settings`t`t`t`t`t: " $RDSGroup.InheritDefaultAgentSettings.ToString() <>                                 Line 3 "Inherit default settings`t`t`t`t: " $RDSGroup.InheritDefaultAgentSettings.ToString()
                                Line 3 "Application session lingering"    
                                Line 4 "Disconnect active session after`t`t`t`t: " $RDSPublishingSessionDisconnectTimeout    
                                Line 4 "Logoff disconnected session after`t`t`t: " $RDSPublishingSessionResetTime    
                                Line 3 "Other settings"    
                                Line 4 "Port`t`t`t`t`t`t`t: " $RDSPort                                   Line 3 "Port`t`t`t`t`t`t`t: " $RDSPort
                                Line 4 "Max Sessions`t`t`t`t`t`t: " $RDSMaxSessions                                   Line 3 "Max Sessions`t`t`t`t`t`t: " $RDSMaxSessions
                                    Line 3 "Publishing Session Disconnect Timeout`t`t`t: " $RDSPublishingSessionDisconnectTimeout
                                Line 4 "Preferred Connection Broker`t`t`t`t: " $RDSPreferredPublishingAgent                                   Line 3 "Publishing Session Reset Timeout`t`t`t: " $RDSPublishingSessionResetTime
                                Line 3 "Allow Client URL/Mail Redirection`t`t`t`t: " $RDSAllowClientURLMailRedirection                                   Line 3 "Allow Client URL/Mail Redirection`t`t`t: " $RDSAllowClientURLMailRedirection
                                Line 4 "Replace registered application`t`t`t`t: " $ReplaceRegisteredApplication    
                                Line 4 "Support Windows Shell URL namespace objects`t`t: " $RDSSupportShellURLNamespaceObject                                   Line 3 "Support Windows Shell URL namespace objects`t`t: " $RDSSupportShellURLNamespaceObject
                                Line 3 "Enable Drag and drop`t`t`t`t`t`t: " $RDSAllowDragandDrop                                   Line 3 "Drag and drop`t`t`t`t`t`t: " $RDSDragAndDrop
                                Line 4 "Direction`t`t`t`t`t`t: " $RDSDragAndDrop                                   Line 3 "Preferred Publishing Agent`t`t`t`t: " $RDSPreferredPublishingAgent
                                Line 3 "Allow 2xRemoteExec to send command to the client`t`t: " $RDSAllowRemoteExec                                   Line 3 "Allow 2xRemoteExec to send command to the client`t: " $RDSAllowRemoteExec
                                Line 3 "Use RemoteApp if available`t`t`t`t`t: " $RDSUseRemoteApps                                   Line 3 "Use RemoteApp if available`t`t`t`t: " $RDSUseRemoteApps
                                Line 3 "Enable applications monitoring`t`t`t`t`t: " $RDSEnableAppMonitoring                                   Line 3 "Enable applications monitoring`t`t`t`t: " $RDSEnableAppMonitoring
                                Line 3 "Allow file transfer command (Web (HTML5) and Chrome clients)`t: " $RDSAllowFileTransfer                                   Line 3 "Allow file transfer command (HTML5 and Chrome clients)`t: " $RDSAllowFileTransfer
                                Line 4 "Configure File Transfer"                                   Line 3 "Configure File Transfer"
                                Line 5 "Direction`t`t`t: " $RDSFileTransferMode                                   Line 4 "Direction`t`t`t: " $RDSFileTransferMode
                                Line 5 "Location`t`t`t: " $RDSFileTransferLocation                                   Line 4 "Location`t`t`t: " $RDSFileTransferLocation
                                Line 5 "Do not allow to change location : " $RDSFileTransferChangeLocation                                   Line 4 "Do not allow to change location`t: " $RDSFileTransferChangeLocation
                                Line 3 "Enable drive redirection cache`t`t`t`t`t: " $RDSEnableDriveRedirectionCache    
 
                                $rowdata += @(,("Application session lingering",($Script:htmlsb),"",$htmlwhite)) <>  
                                $rowdata += @(,("     Disconnect active session after",($Script:htmlsb),$RDSPublishingSessionDisconnectTimeout,$htmlwhite))    
                                $rowdata += @(,("     Logoff disconnected session after",($Script:htmlsb),$RDSPublishingSessionResetTime,$htmlwhite))    
                                $rowdata += @(,("Other settings",($Script:htmlsb),$RDSPort,$htmlwhite))    
                                $rowdata += @(,("     Port",($Script:htmlsb),$RDSPort,$htmlwhite))                                   $rowdata += @(,("Port",($Script:htmlsb),$RDSPort,$htmlwhite))
                                $rowdata += @(,("     Max Sessions",($Script:htmlsb),$RDSMaxSessions,$htmlwhite))                                   $rowdata += @(,("Max Sessions",($Script:htmlsb),$RDSMaxSessions,$htmlwhite))
                                    $rowdata += @(,("Publishing Session Disconnect Timeout",($Script:htmlsb),$RDSPublishingSessionDisconnectTimeout,$htmlwhite))
                                $rowdata += @(,("     Preferred Connection Broker",($Script:htmlsb),$RDSPreferredPublishingAgent,$htmlwhite))                                   $rowdata += @(,("Publishing Session Reset Timeout",($Script:htmlsb),$RDSPublishingSessionResetTime,$htmlwhite))
 
                                $rowdata += @(,("     Replace registered application",($Script:htmlsb),$ReplaceRegisteredApplication,$htmlwhite)) <>  
                                $rowdata += @(,("     Support Windows Shell URL namespace objects",($Script:htmlsb),$RDSSupportShellURLNamespaceObject,$htmlwhite))                                   $rowdata += @(,("Support Windows Shell URL namespace objects",($Script:htmlsb),$RDSSupportShellURLNamespaceObject,$htmlwhite))
                                $rowdata += @(,("Enable Drag and drop",($Script:htmlsb),$RDSAllowDragandDrop,$htmlwhite))                                   $rowdata += @(,("Drag and drop",($Script:htmlsb),$RDSDragAndDrop,$htmlwhite))
                                $rowdata += @(,("     Direction",($Script:htmlsb),$RDSDragAndDrop,$htmlwhite))                                   $rowdata += @(,("Preferred Publishing Agent",($Script:htmlsb),$RDSPreferredPublishingAgent,$htmlwhite))
 
                                $rowdata += @(,("Allow file transfer command (Web (HTML5) and Chrome clients)",($Script:htmlsb),$RDSAllowFileTransfer,$htmlwhite)) <>                                 $rowdata += @(,("Allow file transfer command (HTML5 and Chrome clients)",($Script:htmlsb),$RDSAllowFileTransfer,$htmlwhite))
                                $rowdata += @(,("     Configure File Transfer",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Configure File Transfer",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("          Direction",($Script:htmlsb),$RDSFileTransferMode,$htmlwhite))                                   $rowdata += @(,("     Direction",($Script:htmlsb),$RDSFileTransferMode,$htmlwhite))
                                $rowdata += @(,("          Location",($Script:htmlsb),$RDSFileTransferLocation,$htmlwhite))                                   $rowdata += @(,("     Location",($Script:htmlsb),$RDSFileTransferLocation,$htmlwhite))
                                $rowdata += @(,("          Do not allow to change location",($Script:htmlsb),$RDSFileTransferChangeLocation,$htmlwhite))                                   $rowdata += @(,("     Do not allow to change location",($Script:htmlsb),$RDSFileTransferChangeLocation,$htmlwhite))
                                $rowdata += @(,("Enable drive redirection cache",($Script:htmlsb),$RDSEnableDriveRedirectionCache,$htmlwhite))    
 
                                        #$FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate <>                                         $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
 
                                        #$FSLogixDeploymentSettingsReplicate             = $False <>                                         $FSLogixDeploymentSettingsReplicate             = $False
 
                                #$FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate <>                                 $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
 
                                        #$ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null
 
                                        #Line 3 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString() <>                                         Line 3 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString()
 
                                        #$rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite)) <>                                         $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite))
 
        Write-Verbose "$(Get-Date -Format G): `tOutput RD Session Hosts Templates" <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Host Scheduler"
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Templates"    
        }    
        If($Text)    
        {    
                Line 1 "Templates"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Templates"    
        }    
                    
        $RDSTemplates = Get-RASVDITemplate -Siteid $Site.Id -EA 0 4>$Null | Where-Object {$_.TemplateType -eq "RDSH"}           $RDSSchedules = Get-RASRDSSchedule -Siteid $Site.Id -EA 0 4> $Null
            
 
                Unable to retrieve RD Session Hosts Templates for Site $($Site.Name)` <>                 Unable to retrieve RD Session Host Scheduler for Site $($Site.Name)`
 
                        WriteWordLine 0 0 "Unable to retrieve RD Session Hosts Templates for Site $($Site.Name)" <>                         WriteWordLine 0 0 "Unable to retrieve RD Session Host Scheduler for Site $($Site.Name)"
 
                        Line 0 "Unable to retrieve RD Session Hosts Templates for Site $($Site.Name)" <>                         Line 0 "Unable to retrieve RD Session Host Scheduler for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "Unable to retrieve RD Session Hosts Templates for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "Unable to retrieve RD Session Host Scheduler for Site $($Site.Name)"
 
        ElseIf($? -and $Null -eq $RDSTemplates) <>         ElseIf($? -and $Null -eq $RDSSchedules)
 
        No RD Session Hosts Templates retrieved for Site $($Site.Name).` <>                 No RD Session Host Scheduler retrieved for Site $($Site.Name).`
 
                        WriteWordLine 0 0 "No RD Session Hosts Templates retrieved for Site $($Site.Name)" <>                         WriteWordLine 0 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)"
 
                        Line 0 "No RD Session Hosts Templates retrieved for Site $($Site.Name)" <>                         Line 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "No RD Session Hosts Templates retrieved for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)"
 
                ForEach($RDSTemplate in $RDSTemplates) <>                 If($MSWord -or $PDF)
 
                        $TemplateProvider = Get-RASProvider -Id $RDSTemplate.ProviderId -EA 0 4>$Null <>                         WriteWordLine 2 0 "Scheduler"
                                           }
                        If($? -and $Null -ne $TemplateProvider)                   If($Text)
                        {                   {
                                $TemplateProviderName = $TemplateProvider.Server                           Line 1 "Scheduler"
                                $TemplateProviderType = GetVDIType $TemplateProvider.Type    
                        }                   }
                        Else                   If($HTML)
                        {                   {
                                $TemplateProviderName = ""                           WriteHTMLLine 2 0 "Scheduler"
                                $TemplateProviderType = ""    
                        }                   }
 
                        $TemplateVM = Get-RASVM -Id $RDSTemplate.VMId -ProviderId $RDSTemplate.ProviderId -EA 0 4>$Null <>                 ForEach($RDSSchedule in $RDSSchedules)
                            
                        If($? -and $Null -ne $TemplateVM)    
                        {                   {
                                <#                           Write-Verbose "$(Get-Date -Format G): `t`t`tOutput RD Session Host Scheduler $($RDSSchedule.Name)"
                                        Values          Description                           $Action = $RDSSchedule.Action
                                        Unknown         The VM is in the 'Unknown' state                           If($RDSSChedule.Action -eq "Reboot")
                                        On                  The VM is powered on.    
                                        Off                 The VM is powered off    
                                        Paused          The VM is already, or in the process of being, suspended    
                                        CloningFailed   Failed to clone the VM.    
                                        CloningCanceled VM cloning was cancelled    
                                #>                           {
                                Switch($TemplateVM.State)                                   If($RDSSchedule.DrainMode)
 
                                        "Unknown"                       {$TemplatePowerState = "Unknown"; Break} <>                                         $Action = "Reboot - Drain Mode"
                                        "On"                            {$TemplatePowerState = "Powered on"; Break}    
                                        "Off"                           {$TemplatePowerState = "Powered off"; Break}    
                                        "Paused"                        {$TemplatePowerState = "Paused"; Break}    
                                        "CloningFailed"         {$TemplatePowerState = "Cloning failed"; Break}    
                                        "CloningCanceled"       {$TemplatePowerState = "Cloning canceled"; Break}    
                                        Default                         {$TemplatePowerState = "Unable to determine template VM power state: $($TemplateVM.State)"; Break}    
 
                        } <>  
                        Else                                   Else
                        {                                   {
                                $TemplatePowerState = "Unknown"                                           $Action = "Reboot"
                                    }
 
                         <>  
                        If($MSWord -or $PDF)                           If($Action -eq "Reboot - Drain Mode")
 
                                WriteWordLine 3 0 "Template Name $($RDSTemplate.Name)" <>                                 Switch ($RDSSchedule.CompleteRebootInSecs)
                                $ScriptInformation = New-Object System.Collections.ArrayList                                   {
                                $ScriptInformation.Add(@{Data = "Name"; Value = $RDSTemplate.Name; }) > $Null                                           600             {$TimeDuration = "10 minutes"; Break}
                                #$ScriptInformation.Add(@{Data = "Status"; Value = "Can't find"; }) > $Null                                           900             {$TimeDuration = "15 minutes"; Break}
                                $ScriptInformation.Add(@{Data = "Power state"; Value = $TemplatePowerState; }) > $Null                                           1800    {$TimeDuration = "30 minutes"; Break}
                                #$ScriptInformation.Add(@{Data = "Agent status"; Value = "Can't find"; }) > $Null                                           2700    {$TimeDuration = "45 minutes"; Break}
                                #$ScriptInformation.Add(@{Data = "Distribution"; Value = "Can't find"; }) > $Null                                           3600    {$TimeDuration = "1 hour"; Break}
                                $ScriptInformation.Add(@{Data = "Provider"; Value = $TemplateProviderName; }) > $Null                                           7200    {$TimeDuration = "2 hours"; Break}
                                $ScriptInformation.Add(@{Data = "Provider type"; Value = $TemplateProviderType; }) > $Null                                           10800   {$TimeDuration = "3 hours"; Break}
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $RDSTemplate.AdminLastMod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $RDSTemplate.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $RDSTemplate.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $RDSTemplate.TimeCreate.ToString(); }) > $Null                                           Default {$TimeDuration = "Unable to determine Complete in seconds: $($RDSSchedule.CompleteRebootInSecs)"; Break}
                                $ScriptInformation.Add(@{Data = "ID"; Value = $RDSTemplate.Id.ToString(); }) > $Null    
                                    }
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
                                    
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite                                   Switch ($RDSSchedule.ForceRebootAfterSecs)
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
                                    {
                                $Table.Columns.Item(1).Width = 200;                                           900             {$ForceRebootTime = "15 minutes"; Break}
                                $Table.Columns.Item(2).Width = 250;                                           1800    {$ForceRebootTime = "30 minutes"; Break}
                                            2700    {$ForceRebootTime = "45 minutes"; Break}
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                           3600    {$ForceRebootTime = "1 hour"; Break}
                                            7200    {$ForceRebootTime = "2 hours"; Break}
                                            10800   {$ForceRebootTime = "3 hours"; Break}
                                            21600   {$ForceRebootTime = "6 hours"; Break}
                                            43200   {$ForceRebootTime = "12 hours"; Break}
                                            86400   {$ForceRebootTime = "1 day"; Break}
                                            Default {$ForceRebootTime = "Unable to determine Force reboot after seconds: $($RDSSchedule.ForceRebootAfterSecs)"; Break}
                                    }
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
 
                        If($Text) <>                         ElseIf($Action -eq "Disable")
 
                                Line 2 "Name: " $RDSTemplate.Name <>  
                                #Line 2 "Status`t`t`t: " "Can't find"    
                                Line 2 "Power state`t`t: " $TemplatePowerState    
                                #Line 2 "Agent status`t`t: " "Can't find"    
                                #Line 2 "Distribution`t`t: " "Can't find"    
                                Line 2 "Provider`t`t: " $TemplateProviderName    
                                Line 2 "Provider type`t`t: " $TemplateProviderType    
                                Line 2 "Last modification by`t: " $RDSTemplate.AdminLastMod    
                                Line 2 "Modified on`t`t: " $RDSTemplate.TimeLastMod.ToString()    
                                Line 2 "Created by`t`t: " $RDSTemplate.AdminCreate    
                                Line 2 "Created on`t`t: " $RDSTemplate.TimeCreate.ToString()    
                                Line 2 "ID`t`t`t: " $RDSTemplate.Id.ToString()                                   Switch ($RDSSchedule.DurationInSecs)
                                Line 0 ""                                   {
                                            600             {$TimeDuration = "10 minutes"; Break}
                                            900             {$TimeDuration = "15 minutes"; Break}
                                            1800    {$TimeDuration = "30 minutes"; Break}
                                            2700    {$TimeDuration = "45 minutes"; Break}
                                            3600    {$TimeDuration = "1 hour"; Break}
                                            7200    {$TimeDuration = "2 hours"; Break}
                                            10800   {$TimeDuration = "3 hours"; Break}
                                            21600   {$TimeDuration = "6 hours"; Break}
                                            43200   {$TimeDuration = "12 hours"; Break}
                                            86400   {$TimeDuration = "1 day"; Break}
                                            Default {$TimeDuration = "Unable to determine Duration in seconds: $($RDSSchedule.DurationInSecs)"; Break}
                        }                                   }
                        If($HTML)                                  
                                    Switch ($RDSSchedule.DisableAction)
                        {                                   {
                                $rowdata = @()                                           "KeepSessionState"                      {$OnDisable = "Keep current sessions state"; Break}
                                $columnHeaders = @("Name",($Script:htmlsb),$RDSTemplate.Name,$htmlwhite)                                           "DisconnectActiveSessions"      {$OnDisable = "Disconnect any active session"; Break}
                                #$rowdata += @(,("Status",($Script:htmlsb),"Can't find",$htmlwhite))                                           "ResetAllSessions"                      {$OnDisable = "Reset all sessions"; Break}
                                $rowdata += @(,("Power state",($Script:htmlsb),$TemplatePowerState,$htmlwhite))    
                                #$rowdata += @(,("Agent status",($Script:htmlsb),"Can't find",$htmlwhite))    
                                #$rowdata += @(,("Distribution",($Script:htmlsb),"Can't find",$htmlwhite))    
                                $rowdata += @(,("Provider",($Script:htmlsb),$TemplateProviderName,$htmlwhite))    
                                $rowdata += @(,("Provider type",($Script:htmlsb),$TemplateProviderType,$htmlwhite))    
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $RDSTemplate.AdminLastMod,$htmlwhite))                                           Default                                         {$OnDisable = "Unable to determine On disable: $($RDSSchedule.DisableAction)"; Break}
                                $rowdata += @(,("Modified on",($Script:htmlsb), $RDSTemplate.TimeLastMod.ToString(),$htmlwhite))    
                                $rowdata += @(,("Created by",($Script:htmlsb), $RDSTemplate.AdminCreate,$htmlwhite))    
                                $rowdata += @(,("Created on",($Script:htmlsb), $RDSTemplate.TimeCreate.ToString(),$htmlwhite))    
                                $rowdata += @(,("Id",($Script:htmlsb),$RDSTemplate.Id.ToString(),$htmlwhite))    
                                    }
                                $msg = ""    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
 
  <>                         Switch ($RDSSchedule.Repeat)
                        #General                           {
                                    Never                   {$Repeat = "Never "; Break}
                                    EveryDay                {$Repeat = "Every day"; Break}
                                    EveryWeek               {$Repeat = "Every week"; Break}
                                    Every2Weeks             {$Repeat = "Every 2 weeks"; Break}
                                    EveryMonth              {$Repeat = "Every month"; Break}
                                    EveryYear               {$Repeat = "Every year"; Break}
                                    SpecificDays    {$Repeat = "Every $($RDSSchedule.SpecificDays)"; Break}
                                    Default                 {$Repeat = "Unable to determine the Repeat: $($RDSSchedule.Repeat)"; Break}
                            }
 
                        If($MSWord -or $PDF) <>                         $Target = @()
                            If($RDSSchedule.TargetType -eq "Server")
 
                                WriteWordLine 4 0 "General" <>                                 ForEach($Item in $RDSSchedule.TargetIds)
                                    {
                                            $Result = Get-RASRDS -Id $Item -EA 0 4>$Null
                                            
                                            If($? -and $Null -ne $Result)
                                            {
                                                    $Target += $Result.Server
                        }                                           }
                        If($Text)                                           Else
                        {                                           {
                                Line 2 "General"                                                   Target += "Unable to find RDS Server for ID $($Item)"
                                            }
                                    }
 
                        If($HTML) <>                         ElseIf($RDSSchedule.TargetType -eq "ServerGroup")
 
  <>                                 ForEach($Item in $RDSSchedule.TargetIds)
                                #Nothing                                   {
                                            $Result = Get-RASRDSGroup -Id $Item -EA 0 4>$Null
                                            
                                            If($? -and $Null -ne $Result)
                                            {
                                                    $Target += $Result.Name
                        }                                           }
                                                                  Else
                        Switch($RDSTemplate.UnusedVMDurationMins)    
                        {                                           {
                                0               {$DeleteVMTime = "Never"; Break}                                                   Target += "Unable to find RDS Server Group for ID $($Item)"
                                5               {$DeleteVMTime = "5 minutes"; Break}                                           }
                                30              {$DeleteVMTime = "30 minutes"; Break}    
                                60              {$DeleteVMTime = "1 hour"; Break}    
                                1440    {$DeleteVMTime = "1 day"; Break}    
                                10080   {$DeleteVMTime = "1 week"; Break}    
                                43200   {$DeleteVMTime = "30 days"; Break}    
                                Default {$DeleteVMTime = "Unable to determine Delete unused guest VMs after: $($RDSTemplate.UnusedVMDurationMins)"; Break}    
                        }                                   }
                                                  }
                        Switch($RDSTemplate.CloneMethod)                           Else
 
                                "LinkedClone"   {$CloneMethod = "Create a linked clone"; Break} <>  
                                "FullClone"             {$CloneMethod = "Create a full clone"; Break}    
                                Default                 {$CloneMethod = "Unable to determine Clone method: $($RDSTemplate.CloneMethod)"; Break}                                   Target += "Unable to determine Target for TargetType: $($RDSSchedule.TargetType)"
 
  <>                         
 
  -+                                 WriteWordLine 3 0 "Schedule Name $($RDSSchedule.Name)"
 
                                $ScriptInformation.Add(@{Data = "Template name"; Value = $RDSTemplate.Name; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Name"; Value = $RDSSchedule.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Action"; Value = $Action; }) > $Null
                                    
                                    $cnt=-1
                                    ForEach($Item in $Target)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                $ScriptInformation.Add(@{Data = "Maximum guest VMs"; Value = $RDSTemplate.MaxVMs.ToString(); }) > $Null                                                   $ScriptInformation.Add(@{Data = "Target"; Value = $Item; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    
                                $ScriptInformation.Add(@{Data = "Keep available buffer"; Value = $RDSTemplate.PreCreatedVMs.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Start"; Value = $RDSSchedule.StartDateTime; }) > $Null
                                $ScriptInformation.Add(@{Data = "Guest VM name"; Value = $RDSTemplate.VMNameFormat; }) > $Null                                   $ScriptInformation.Add(@{Data = "Repeat"; Value = $Repeat; }) > $Null
                                $ScriptInformation.Add(@{Data = "Guest VM state after the preparation"; Value = "Can't find"; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $RDSSchedule.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $RDSSchedule.AdminLastMod; }) > $Null
                                $ScriptInformation.Add(@{Data = "Delete unused guest VMs after"; Value = $DeleteVMTime; }) > $Null                                   $ScriptInformation.Add(@{Data = "Modified on"; Value = $RDSSchedule.TimeLastMod.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Clone method"; Value = $CloneMethod; }) > $Null                                   $ScriptInformation.Add(@{Data = "Created by"; Value = $RDSSchedule.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $RDSSchedule.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "ID"; Value = $RDSSchedule.Id.ToString(); }) > $Null
 
  <>                                 Line 2 "Name`t`t`t: " $RDSSchedule.Name
                                    Line 2 "Action`t`t`t: " $Action
                                    
                                    $cnt=-1
                                    ForEach($Item in $Target)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                                    Line 2 "Target`t`t`t: " $Item
                                            }
                                            Else
                                            {
                                                    Line 6 "  " $Item
                                            }
                                    }
                                    
                                Line 3 "Template name`t`t`t`t`t: " $RDSTemplate.Name                                   Line 2 "Start`t`t`t: " $RDSSchedule.StartDateTime
                                    Line 2 "Repeat`t`t`t: " $Repeat
                                    Line 2 "Description`t`t: " $RDSSchedule.Description
                                    Line 2 "Last modification by`t: " $RDSSchedule.AdminLastMod
                                Line 3 "Maximum guest VMs`t`t`t`t: " $RDSTemplate.MaxVMs.ToString()                                   Line 2 "Modified on`t`t: " $RDSSchedule.TimeLastMod.ToString()
                                    Line 2 "Created by`t`t: " $RDSSchedule.AdminCreate
                                Line 3 "Keep available buffer`t`t`t`t: " $RDSTemplate.PreCreatedVMs.ToString()                                   Line 2 "Created on`t`t: " $RDSSchedule.TimeCreate.ToString()
                                Line 3 "Guest VM name`t`t`t`t`t: " $RDSTemplate.VMNameFormat                                   Line 2 "ID`t`t`t: " $RDSSchedule.Id.ToString()
                                Line 3 "Guest VM state after the preparation`t: " "Can't find"    
                                Line 3 "Delete unused guest VMs after`t`t`t: " $DeleteVMTime    
                                Line 3 "Clone method`t`t`t`t`t: " $CloneMethod    
 
  -+                                 WriteHTMLLine 3 0 "Schedule Name $($RDSSchedule.Name)"
 
                                $columnHeaders = @("Template name",($Script:htmlsb),$RDSTemplate.Name,$htmlwhite) <>                                 $columnHeaders = @("Name",($Script:htmlsb),$RDSSchedule.Name,$htmlwhite)
                                    $rowdata += @(,("Action",($Script:htmlsb),$Action,$htmlwhite))
                                    
                                    $cnt=-1
                                    ForEach($Item in $Target)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                $rowdata += @(,("Maximum guest VMs",($Script:htmlsb),$RDSTemplate.MaxVMs.ToString(),$htmlwhite))                                                   $rowdata += @(,("Target",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    
                                $rowdata += @(,("Keep available buffer",($Script:htmlsb),$RDSTemplate.PreCreatedVMs.ToString(),$htmlwhite))                                   $rowdata += @(,("Start",($Script:htmlsb),$RDSSchedule.StartDateTime,$htmlwhite))
                                $rowdata += @(,("Guest VM name",($Script:htmlsb),$RDSTemplate.VMNameFormat,$htmlwhite))                                   $rowdata += @(,("Repeat",($Script:htmlsb),$Repeat,$htmlwhite))
                                $rowdata += @(,("Guest VM state after the preparation",($Script:htmlsb),"Can't find",$htmlwhite))                                   $rowdata += @(,("Description",($Script:htmlsb),$RDSSchedule.Description,$htmlwhite))
                                    $rowdata += @(,("Last modification by",($Script:htmlsb),$RDSSchedule.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb),$RDSSchedule.TimeLastMod.ToString(),$htmlwhite))
                                $rowdata += @(,("Delete unused guest VMs after",($Script:htmlsb),$DeleteVMTime,$htmlwhite))                                   $rowdata += @(,("Created by",($Script:htmlsb),$RDSSchedule.AdminCreate,$htmlwhite))
                                $rowdata += @(,("Clone method",($Script:htmlsb),$CloneMethod,$htmlwhite))                                   $rowdata += @(,("Created on",($Script:htmlsb),$RDSSchedule.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("ID",($Script:htmlsb),$RDSSchedule.Id.ToString(),$htmlwhite))
 
                                $msg = "General" <>                                 $msg = ""
                                $columnWidths = @("300","275")                                   $columnWidths = @("200","275")
 
                        #Advanced <>                         #Properties
 
                                WriteWordLine 4 0 "Advanced" <>                                 WriteWordLine 4 0 "General"
 
                                Line 2 "Advanced" <>                                 Line 2 "General"
 
                                $ScriptInformation.Add(@{Data = "Folder"; Value = $RDSTemplate.FolderName; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Enable Schedule"; Value = $RDSSchedule.Enabled.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Resource pool"; Value = $RDSTemplate.NativePoolName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Name"; Value = $RDSSchedule.Name; }) > $Null
                                $ScriptInformation.Add(@{Data = "Physical Host"; Value = $RDSTemplate.PhysicalHostName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Action"; Value = $Action; }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable hardware acceleration graphics licensing support"; Value = $RDSTemplate.HWGPU.ToString(); }) > $Null    
                                #$ScriptInformation.Add(@{Data = "Use a separate network interface for LAN access"; Value = "Can't find"; }) > $Null    
                                #$ScriptInformation.Add(@{Data = "Specify management network details"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $RDSSchedule.Description; }) > $Null
                                    
                                    $cnt=-1
                                    ForEach($Item in $Target)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                #$ScriptInformation.Add(@{Data = "     Address"; Value = ""; }) > $Null                                                   $ScriptInformation.Add(@{Data = "Target"; Value = $Item; }) > $Null
                                            }
                                            Else
                                            {
                                #$ScriptInformation.Add(@{Data = "     Subnet mask"; Value = ""; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
 
                                $Table.Columns.Item(1).Width = 250; <>                                 $Table.Columns.Item(1).Width = 200;
 
                                Line 3 "Folder`t`t`t`t: " $RDSTemplate.FolderName <>                                 Line 3 "Enable Schedule`t`t`t: " $RDSSchedule.Enabled.ToString()
                                Line 3 "Resource pool`t`t`t: " $RDSTemplate.NativePoolName                                   Line 3 "Name`t`t`t`t: " $RDSSchedule.Name
                                Line 3 "Physical Host`t`t`t: " $RDSTemplate.PhysicalHostName                                   Line 3 "Action`t`t`t`t: " $Action
                                Line 3 "Enable hardware acceleration "    
                                Line 3 "graphics licensing support`t: " $RDSTemplate.HWGPU.ToString()                                   Line 3 "Description`t`t`t: " $RDSSchedule.Description
                                #Line 3 "Use a separate network interface for LAN access: " "Can't find"                                  
                                #Line 3 "Specify management network details:"                                   $cnt=-1
                                    ForEach($Item in $Target)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                #Line 4 "Address`t`t`t: " $DeleteVMTime                                                   Line 3 "Target`t`t`t`t: " $Item
                                #Line 4 "Subnet mask`t`t: " $CloneMethod                                           }
                                            Else
                                            {
                                                    Line 7 "  " $Item
                                            }
                                    }
 
                                $columnHeaders = @("Folder",($Script:htmlsb),$RDSTemplate.FolderName,$htmlwhite) <>                                 $columnHeaders = @("Enable schedule",($Script:htmlsb),$RDSSchedule.Enabled.ToString(),$htmlwhite)
                                $rowdata += @(,("Resource pool",($Script:htmlsb),$RDSTemplate.NativePoolName,$htmlwhite))                                   $rowdata += @(,("Name",($Script:htmlsb),$RDSSchedule.Name,$htmlwhite))
                                $rowdata += @(,("Physical Host",($Script:htmlsb),$RDSTemplate.PhysicalHostName,$htmlwhite))                                   $rowdata += @(,("Action",($Script:htmlsb),$Action,$htmlwhite))
                                $rowdata += @(,("Enable hardware acceleration graphics licensing support",($Script:htmlsb),$RDSTemplate.HWGPU.ToString(),$htmlwhite))                                   $rowdata += @(,("Description",($Script:htmlsb),$RDSSchedule.Description,$htmlwhite))
                                #$rowdata += @(,("Use a separate network interface for LAN access",($Script:htmlsb),"Can't find",$htmlwhite))                                  
                                #$rowdata += @(,("Specify management network details",($Script:htmlsb),"",$htmlwhite))                                   $cnt=-1
                                    ForEach($Item in $Target)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                #$rowdata += @(,("     Address",($Script:htmlsb),"",$htmlwhite))                                                   $rowdata += @(,("Target",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                            Else
                                            {
                                #$rowdata += @(,("     Subnet mask",($Script:htmlsb),"",$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    
                                $msg = "Advanced"                                   $msg = "General"
                                $columnWidths = @("300","275")                                   $columnWidths = @("200","275")
 
                         <>  
                        #Preparation                           #Trigger
 
                                WriteWordLine 4 0 "Preparation" <>                                 WriteWordLine 4 0 "Trigger"
 
                                Line 2 "Preparation" <>                                 Line 2 "Trigger"
 
                                $ScriptInformation.Add(@{Data = "Image preparation tool"; Value = $RDSTemplate.ImagePrepTool.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Date"; Value = $RDSSchedule.StartDateTime.ToShortDateString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Computer name"; Value = $RDSTemplate.ComputerName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Start"; Value = $RDSSchedule.StartDateTime.ToShortTimeString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Owner name"; Value = $RDSTemplate.OwnerName; }) > $Null                                   If($Action -eq "Reboot - Drain Mode")
                                $ScriptInformation.Add(@{Data = "Organization"; Value = $RDSTemplate.Organization; }) > $Null                                   {
                                $ScriptInformation.Add(@{Data = "Active Directory domain"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "Complete in"; Value = $TimeDuration  ; }) > $Null
                                    }
                                    ElseIf($Action -eq "Disable")
                                    {
                                $ScriptInformation.Add(@{Data = "     Domain"; Value = $RDSTemplate.Domain; }) > $Null                                           $ScriptInformation.Add(@{Data = "Duration"; Value = $TimeDuration; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Administrator"; Value = $RDSTemplate.Administrator; }) > $Null                                   }
                                $ScriptInformation.Add(@{Data = "     Target OU"; Value = $RDSTemplate.DomainOrgUnit; }) > $Null                                   $ScriptInformation.Add(@{Data = "Repeat"; Value = $Repeat; }) > $Null
 
                                $Table.Columns.Item(1).Width = 250; <>                                 $Table.Columns.Item(1).Width = 200;
 
                                Line 3 "Image preparation tool`t: " $RDSTemplate.ImagePrepTool.ToString() <>                                 Line 3 "Date`t`t`t`t: " $RDSSchedule.StartDateTime.ToShortDateString()
                                Line 3 "Computer name`t`t: " $RDSTemplate.ComputerName    
                                Line 3 "Owner name`t`t: " $RDSTemplate.OwnerName    
                                Line 3 "Organization`t`t: " $RDSTemplate.Organization    
                                Line 3 "Active Directory domain"    
                                Line 4 "Domain`t`t: " $RDSTemplate.Domain    
                                Line 4 "Administrator`t: " $RDSTemplate.Administrator                                   Line 3 "Start`t`t`t`t: " $RDSSchedule.StartDateTime.ToShortTimeString()
                                Line 4 "Target OU`t: " $RDSTemplate.DomainOrgUnit    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Image preparation tool",($Script:htmlsb),$RDSTemplate.ImagePrepTool.ToString(),$htmlwhite)    
                                $rowdata += @(,("Computer name",($Script:htmlsb),$RDSTemplate.ComputerName,$htmlwhite))    
                                $rowdata += @(,("Owner name",($Script:htmlsb),$RDSTemplate.OwnerName,$htmlwhite))    
                                $rowdata += @(,("Organization",($Script:htmlsb),$RDSTemplate.Organization,$htmlwhite))    
                                $rowdata += @(,("Active Directory domain",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("     Domain",($Script:htmlsb),$RDSTemplate.Domain,$htmlwhite))    
                                $rowdata += @(,("     Administrator",($Script:htmlsb),$RDSTemplate.Administrator,$htmlwhite))    
                                $rowdata += @(,("     Target OU",($Script:htmlsb),$RDSTemplate.DomainOrgUnit,$htmlwhite))    
     
                                $msg = "Preparation"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
                        #Optimization    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Optimization"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Optimization"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
     
                        If($RDSTemplate.InheritDefaultOptimizationSettings)    
                        {    
                                #do we inherit site defaults?    
                                #http://woshub.com/hot-to-convert-sid-to-username-and-vice-versa/    
                                #for translating the User SID to the AD user name    
                                #yes we do, get the default settings for the Site    
                                #use the Site default settings    
                                $RDSDefaults = Get-RASRDSDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $RDSDefaults)    
                                {    
                                        $OPTEnableOptimization            = $RDSDefaults.Optimization.EnableOptimization.ToString()    
                                        $OPTOptimizationType              = $RDSDefaults.Optimization.OptimizationType.ToString()    
                                        $OPTWindowsDefenderATPEnabled     = $RDSDefaults.Optimization.WindowsDefenderATPEnabled.ToString()        
                                        $OPTWindowsComponentsEnabled      = $RDSDefaults.Optimization.WindowsComponentsEnabled.ToString()    
                                        $OPTWindowsServicesEnabled        = $RDSDefaults.Optimization.WindowsServicesEnabled.ToString()    
                                        $OPTWinodwsScheduledTasksEnabled  = $RDSDefaults.Optimization.WindowsScheduledTasksEnabled.ToString()    
                                        $OPTWindowsAdvancedOptionsEnabled = $RDSDefaults.Optimization.WindowsAdvancedOptionsEnabled.ToString()    
                                        $OPTNetworkPerformanceEnabled     = $RDSDefaults.Optimization.NetworkPerformanceEnabled.ToString()    
                                        $OPTRegistryEnabled               = $RDSDefaults.Optimization.RegistryEnabled.ToString()    
                                        $OPTVisualEffectsEnabled          = $RDSDefaults.Optimization.VisualEffectsEnabled.ToString()       
                                        $OPTDiskCleanupEnabled            = $RDSDefaults.Optimization.DiskCleanupEnabled.ToString()    
                                        $OPTCustomScriptEnabled           = $RDSDefaults.Optimization.CustomScriptEnabled.ToString()    
                                }    
                                Else    
                                {    
                                        #unable to retrieve default, use built-in default values    
                                        $OPTEnableOptimization            = "False"    
                                        $OPTOptimizationType              = ""    
                                        $OPTWindowsDefenderATPEnabled     = "False"    
                                        $OPTWindowsComponentsEnabled      = "False"    
                                        $OPTWindowsServicesEnabled        = "False"    
                                        $OPTWinodwsScheduledTasksEnabled  = "False"    
                                        $OPTWindowsAdvancedOptionsEnabled = "False"    
                                        $OPTNetworkPerformanceEnabled     = "False"    
                                        $OPTRegistryEnabled               = "False"    
                                        $OPTVisualEffectsEnabled          = "False"    
                                        $OPTDiskCleanupEnabled            = "False"    
                                        $OPTCustomScriptEnabled           = "False"    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit    
                                #get the settings for the template    
                                    
                                $OPTEnableOptimization            = $RDSTemplate.Optimization.EnableOptimization.ToString()    
                                $OPTOptimizationType              = $RDSTemplate.Optimization.OptimizationType.ToString()    
                                $OPTWindowsDefenderATPEnabled     = $RDSTemplate.Optimization.WindowsDefenderATPEnabled.ToString()        
                                $OPTWindowsComponentsEnabled      = $RDSTemplate.Optimization.WindowsComponentsEnabled.ToString()    
                                $OPTWindowsServicesEnabled        = $RDSTemplate.Optimization.WindowsServicesEnabled.ToString()    
                                $OPTWinodwsScheduledTasksEnabled  = $RDSTemplate.Optimization.WindowsScheduledTasksEnabled.ToString()    
                                $OPTWindowsAdvancedOptionsEnabled = $RDSTemplate.Optimization.WindowsAdvancedOptionsEnabled.ToString()    
                                $OPTNetworkPerformanceEnabled     = $RDSTemplate.Optimization.NetworkPerformanceEnabled.ToString()    
                                $OPTRegistryEnabled               = $RDSTemplate.Optimization.RegistryEnabled.ToString()    
                                $OPTVisualEffectsEnabled          = $RDSTemplate.Optimization.VisualEffectsEnabled.ToString()       
                                $OPTDiskCleanupEnabled            = $RDSTemplate.Optimization.DiskCleanupEnabled.ToString()    
                                $OPTCustomScriptEnabled           = $RDSTemplate.Optimization.CustomScriptEnabled.ToString()    
                        }    
     
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $RDSTemplate.InheritDefaultUserProfileSettings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable optimization"; Value = $OPTEnableOptimization; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Optimization type"; Value = $OPTOptimizationType; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 250;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
     
                                WriteWordLine 5 0 "Windows Defender ATP:" $OPTWindowsDefenderATPEnabled    
                                If($OPTWindowsDefenderATPEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Windows Defender ATP Optimizations"; Value = ""; }) > $Null    
     
                                        If($RDSTemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "     Turn off Windows Defender ATP (I use my own ATP solution)"; Value = ""; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = "     Turn on Windows Defender ATP and set process and folder exclusions"; Value = ""; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "     Disable real-time protection"; Value = $RDSTemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(); }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                    
                                                $cnt = -1    
                                                ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeFolders)    
                                                {    
                                                        $cnt++    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "     Exclude files and folders"; Value = $item; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null    
                                                        }    
                                                }    
     
                                                $cnt = -1    
                                                ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)    
                                                {    
                                                        $cnt++    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "     Exclude processes"; Value = $item; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null    
                                                        }    
                                                }    
                                                    
                                                $cnt = -1    
                                                ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeExtension)    
                                                {    
                                                        $cnt++    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "     Exclude extensions"; Value = $item; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null    
                                                        }    
                                                }    
                                        }    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 250;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
     
                                WriteWordLine 5 0 "Windows Components:" $OPTWindowsComponentsEnabled    
                                If($OPTWindowsComponentsEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Windows Components Optimizations"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Disable (remove) components:"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        ForEach($item in $RDSTemplate.Optimization.WindowsComponents.WindowsComponentsList)    
                                        {    
                                                        If($Null -eq $item.DisplayName)    
                                                        {    
                                                                $DisplayName = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $DisplayName = $item.DisplayName    
                                                        }    
                                                        If($Null -eq $item.ComponentName)    
                                                        {    
                                                                $ComponentName = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ComponentName = $item.ComponentName    
                                                        }    
                                                $OptimizationTable += @{    
                                                        DisplayName = $DisplayName    
                                                        ComponentName = $ComponentName    
                                                }    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns DisplayName, ComponentName `    
                                                -Headers "Display name", "Component" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 200;    
                                                $Table.Columns.Item(2).Width = 200;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
     
                                WriteWordLine 5 0 "Windows Services: " $OPTWindowsServicesEnabled           
                                If($OPTWindowsServicesEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Windows Services Optimizations"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Disable services:"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        ForEach($item in $RDSTemplate.Optimization.WindowsServices.WindowsServicesList)    
                                        {    
                                                        If($Null -eq $item.DisplayName)    
                                                        {    
                                                                $DisplayName = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $DisplayName = $item.DisplayName    
                                                        }    
                                                        If($Null -eq $item.ServiceName)    
                                                        {    
                                                                $Service = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $Service = $item.ServiceName    
                                                        }    
                                                        If($Null -eq $item.Aliases)    
                                                        {    
                                                                $Aliases = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $Aliases = $item.Aliases    
                                                        }    
                                                $OptimizationTable += @{    
                                                        DisplayName = $DisplayName    
                                                        Service     = $Service    
                                                        Aliases     = $Aliases    
                                                }    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns DisplayName, Service, Aliases `    
                                                -Headers "Display name", "Service", "Aliases" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 200;    
                                                $Table.Columns.Item(2).Width = 100;    
                                                $Table.Columns.Item(3).Width = 50;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
                                    
                                WriteWordLine 5 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled     
                                If($OPTWinodwsScheduledTasksEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Windows Scheduled Tasks Optimizations"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Disable tasks:"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        ForEach($item in $RDSTemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)    
                                        {    
                                                        If($Null -eq $item.Task)    
                                                        {    
                                                                $Task = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $Task = $item.Task    
                                                        }    
                                                        If($Null -eq $item.Type)    
                                                        {    
                                                                $Type = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $Type = $item.Type.ToString()    
                                                        }    
                                                        If($Null -eq $item.Location)    
                                                        {    
                                                                $Location = ""    
                                                        }    
                                                        Else    
                                                        {    
                                                                $Location = $item.Location    
                                                        }    
                                                $OptimizationTable += @{    
                                                        Task     = $Task    
                                                        Type     = $Type    
                                                        Location = $Location    
                                                }    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns Task, Type, Location `    
                                                -Headers "Task", "Type", "Location" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 200;    
                                                $Table.Columns.Item(2).Width = 50;    
                                                $Table.Columns.Item(3).Width = 250;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
                                    
                                WriteWordLine 5 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled    
                                If($OPTWindowsAdvancedOptionsEnabled -eq "True")                                   If($Action -eq "Reboot - Drain Mode")
 
                                        $ScriptInformation = New-Object System.Collections.ArrayList <>  
                                        $ScriptInformation.Add(@{Data = "Windows Advanced Options"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        $OptimizationTable += @{    
                                                Setting = "Disable Hibernate"    
                                                Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable Telemetry collection"    
                                                Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable System Restore"    
                                                Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable error reporting to send additional data"    
                                                Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable Tiles"    
                                                Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable Cortana digital assistant"    
                                                Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Turn off Microsoft consumer experience"    
                                                Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Do not show Windows tips"    
                                                Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Remove Common program groups from the Start Menu"    
                                                Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Partial Start Menu layout"    
                                                Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString()    
                                                Value   = $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns Setting, Enabled, Value `    
                                                -Headers "Setting", "Enabled", "Value" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 275;    
                                                $Table.Columns.Item(2).Width = 50;    
                                                $Table.Columns.Item(3).Width = 175;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
                                    
                                WriteWordLine 5 0 "Network performance: " $OPTNetworkPerformanceEnabled    
                                If($OPTNetworkPerformanceEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Network Performance Optimizations"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        $OptimizationTable += @{    
                                                Setting = "FileInfoCacheEntriesMax"    
                                                Enabled = $RDSTemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString()    
                                                Value   = $RDSTemplate.Optimization.NetworkPerformance.FileInfoCache    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "DirectoryCacheEntriesMax"    
                                                Enabled = $RDSTemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString()    
                                                Value   = $RDSTemplate.Optimization.NetworkPerformance.DirCacheMax    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "FileNotFoundCacheEntriesMax"    
                                                Enabled = $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString()    
                                                Value   = $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCache    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "DormantFileLimit"                                           Line 3 "Complete in`t`t`t: " $TimeDuration
                                                Enabled = $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString()    
                                                Value   = $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimit    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable TCP/IP Task Offload"    
                                                Enabled = $RDSTemplate.Optimization.NetworkPerformance.DisableTCP.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable IPv6 Components"    
                                                Enabled = $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disable IPv6 to IPv4"    
                                                Enabled = $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString()    
                                                Value   = ""    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Disables isatap for IPv6"    
                                                Enabled = $RDSTemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString()    
                                                Value   = ""    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns Setting, Enabled, Value `    
                                                -Headers "Setting", "Enabled", "Value" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 150;    
                                                $Table.Columns.Item(2).Width = 50;    
                                                $Table.Columns.Item(3).Width = 50;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
 
  <>  
                                WriteWordLine 5 0 "Registry: " $OPTRegistryEnabled    
                                If($OPTRegistryEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Registry Optimizations"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
     
                                        ForEach($item in $RDSTemplate.Optimization.Registry.RegistryList)    
                                        {    
                                                If($item.RegType.ToString() -eq "REG_SZ" -or $item.RegType.ToString() -eq "REG_EXPAND_SZ")    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType.ToString(); }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Data"; Value = $item.StringValue; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                }    
                                                ElseIf($item.RegType.ToString() -eq "REG_DWORD" -or $item.RegType.ToString() -eq "REG_QWORD")    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType.ToString(); }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Data"; Value = $item.DWORDValue; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                }    
                                                ElseIf($item.RegType.ToString() -eq "REG_MULTI_SZ")    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType.ToString(); }) > $Null    
                                                        $cnt = -1    
                                                        $TmpArray = $item.StringValue.Split("`r")    
                                                        ForEach($SubItem in $TmpArray)    
                                                        {    
                                                                $cnt++    
                                                                    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = "Type"; Value = $SubItem; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = $SubItem; }) > $Null    
                                                                }    
                                                        }    
                                                        $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                }    
                                        }    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 125;    
                                        $Table.Columns.Item(2).Width = 375;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                    
                                WriteWordLine 5 0 "Visual Effects: " $OPTVisualEffectsEnabled    
                                If($OPTVisualEffectsEnabled -eq "True")                                   ElseIf($Action -eq "Disable")
 
                                        $ScriptInformation = New-Object System.Collections.ArrayList <>  
                                        $ScriptInformation.Add(@{Data = "Visual Effects Optimizations"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        $OptimizationTable += @{    
                                                Setting = "Animate controls and elements inside windows"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Animate windows when minimizing and maximizing"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Animations in the taskbar"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.AnimateTaskbar.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Enable Peek"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.EnablePeek.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Fade or slide menus into view"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.FadeSlideMenus.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Fade or slide Tooltips into view"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Fade out menu items after clicking"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Save taskbar thumbnail previews"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Show shadows under mouse pointer"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Show shadows under windows"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Show thumbnails instead of icons"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Show translucent selection rectangle"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Show window contents while dragging"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Slide open combo boxes"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Smooth edges of screen fonts"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Smooth-scroll list boxes"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Use drop shadows for icon labels on the desktop"    
                                                Enabled = $RDSTemplate.Optimization.VisualEffects.DropShadowsIcon.ToString()    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns Setting, Enabled `    
                                                -Headers "Setting", "Enabled" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 250;    
                                                $Table.Columns.Item(2).Width = 50;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
                                    
                                WriteWordLine 5 0 "Disk cleanup: " $OPTDiskCleanupEnabled    
                                If($OPTDiskCleanupEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Disk Cleanup Optimizations"; Value = ""; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 15;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $OptimizationTable = @()    
                    
                                        $OptimizationTable += @{    
                                                Setting = "Clean up redundant system files"    
                                                Enabled = $RDSTemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Clean up the WinSxS Folder"    
                                                Enabled = $RDSTemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Clean up temporary files and logs"    
                                                Enabled = $RDSTemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Remove OneDrive"    
                                                Enabled = $RDSTemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString()    
                                        }    
     
                                        $OptimizationTable += @{    
                                                Setting = "Delete users' profiles"    
                                                Enabled = $RDSTemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString()    
                                        }    
     
                                        If($OptimizationTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                -Columns Setting, Enabled `    
                                                -Headers "Setting", "Enabled" `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 175;    
                                                $Table.Columns.Item(2).Width = 50;    
                                                    
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
     
                                WriteWordLine 5 0 "Custom script: " $OPTCustomScriptEnabled    
                                If($OPTCustomScriptEnabled -eq "True")    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Custom Script"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Command"; Value = $RDSTemplate.Optimization.CustomScript.Command; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Arguments"; Value = $RDSTemplate.Optimization.CustomScript.Arguments; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Initial directory"; Value = $RDSTemplate.Optimization.CustomScript.InitDir; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Username"; Value = $RDSTemplate.Optimization.CustomScript.User; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 100;    
                                        $Table.Columns.Item(2).Width = 200;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Inherit default settings`t: " $RDSTemplate.InheritDefaultOptimizationSettings.ToString()    
                                Line 3 "Enable optimization`t`t: " $OPTEnableOptimization    
                                Line 3 "Optimization type`t`t: " $OPTOptimizationType                                           Line 3 "Duration`t`t`t: " $TimeDuration
                                Line 3 "Category"    
                                    
                                Line 4 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled    
                                If($OPTWindowsDefenderATPEnabled -eq "True")    
                                {    
                                        Line 5 "Windows Defender ATP Optimizations"    
                                        If($RDSTemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")    
                                        {    
                                                Line 6 "Turn off Windows Defender ATP (I use my own ATP solution)"    
                                        }    
                                        Else    
                                        {    
                                                Line 6 "Turn on Windows Defender ATP and set process and folder exclusions"    
                                                Line 6 "Disable real-time protection: " $RDSTemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString()    
                                                Line 0 ""    
                                                Line 6 "Exclude files and folders:"    
                                                ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeFolders)    
                                                {    
                                                        Line 7 $item    
                                                }    
     
                                                Line 6 "Exclude processes:"    
                                                ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)    
                                                {    
                                                        Line 7 $item    
                                                }    
                                                    
                                                Line 6 "Exclude extensions:"    
                                                ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeExtension)    
                                                {    
                                                        Line 7 $item    
                                                }    
                                        }    
                                            
                                        Line 0 ""    
 
                                <>                                 Line 3 "Repeat`t`t`t`t: " $Repeat
                                Line 4 "Windows Components: " $OPTWindowsComponentsEnabled    
                                If($OPTWindowsComponentsEnabled -eq "True")    
                                {    
                                        Line 5 "Windows Components Optimizations"    
                                        Line 6 "Disable (remove) components:"    
                                        Line 0 ""    
                                        Line 6 "Display name                                        Component                                         "    
                                        Line 6 "======================================================================================================"    
                                        #               12345678901234567890123456789012345678901234567890SS12345678901234567890123456789012345678901234567890    
                                        #               Printing-XPSServices-Features                       SMB 1.0/CIFS File sharing support component    
                                        ForEach($item in $RDSTemplate.Optimization.WindowsComponents.WindowsComponentsList)    
                                        {    
                                                Line 6 ( "{0,-50}  {1,-50}" -f $item.DisplayName, $item.ComponentName)    
                                        }    
                                        Line 0 ""    
                                }    
                                    
                                Line 4 "Windows Services: " $OPTWindowsServicesEnabled           
                                If($OPTWindowsServicesEnabled -eq "True")    
                                {    
                                        Line 5 "Windows Services Optimizations"    
                                        Line 6 "Disable services:"    
                                        Line 0 ""    
                                        Line 6 "Display name                                        Service                         Aliases             "    
                                        Line 6 "========================================================================================================"    
                                        #               12345678901234567890123456789012345678901234567890SS123456789012345678901234567890SS12345678901234567890    
                                        #               Windows Media Player Network Sharing Service        TabletInputService              Superfecth    
                                        ForEach($item in $RDSTemplate.Optimization.WindowsServices.WindowsServicesList)    
                                        {    
                                                Line 6 ( "{0,-50}  {1,-30}  {2,-20}" -f $item.DisplayName, $item.ServiceName, $item.Aliases)    
                                        }    
                                        Line 0 ""    
                                }    
                                    
                                Line 4 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled     
                                If($OPTWinodwsScheduledTasksEnabled -eq "True")    
                                {    
                                        Line 5 "Windows Scheduled Tasks Optimizations"    
                                        Line 6 "Disable tasks:"    
                                        Line 0 ""    
                                        Line 6 "Task                                                Type    Location                                          "    
                                        Line 6 "=============================================================================================================="    
                                        #               12345678901234567890123456789012345678901234567890SS123456SS12345678901234567890123456789012345678901234567890    
                                        #               MNO Metadata Parser                                 Folder  \Microsoft\Windows\Mobile Broadband Accounts\    
                                        ForEach($item in $RDSTemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)    
                                        {    
                                                Line 6 ( "{0,-50}  {1,-6}  {2,-50}" -f $item.Task, $item.Type.ToString(), $item.Location)    
                                        }    
                                        Line 0 ""    
                                }    
     
                                Line 4 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled    
                                If($OPTWindowsAdvancedOptionsEnabled -eq "True")    
                                {    
                                        Line 5 "Windows Advanced Options"    
                                        Line 0 ""    
                                        Line 6 "Setting                                           Enabled  Value                                             "    
                                        Line 6 "============================================================================================================="    
                                        #               123456789012345678901234567890123456789012345678SS1234567SS12345678901234567890123456789012345678901234567890    
                                        #               Remove Common program groups from the start menu  False    SomeConfigFile.xml    
                                        Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Disable Hibernate", `    
                                        $RDSTemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString(), `    
                                        "")    
                                            
                                        Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Disable Telemetry collection", `    
                                        $RDSTemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(), `    
                                        "")    
                                            
                                        Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Disable System Restore", `    
                                        $RDSTemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(), `    
                                        "")    
                                            
                                        Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Disable error reporting to send additional data", `    
                                        $RDSTemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(), `    
                                        "")    
                                            
                                        Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Disable Tiles", `    
                                        $RDSTemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString(), `    
                                        "")    
                                            
                                        Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Disable Cortana digital assistant", `    
                                        $RDSTemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString(), `    
                                        "")    
                                            
                                        Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Turn off Microsoft consumer experience", `    
                                        $RDSTemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(), `    
                                        "")    
                                            
                                        Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Do not show Windows tips", `    
                                        $RDSTemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(), `    
                                        "")    
                                            
                                        Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Remove Common program groups from the Start Menu", `    
                                        $RDSTemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(), `    
                                        "")    
                                            
                                        Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                        "Partial Start Menu layout", `    
                                        $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(), `    
                                        $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent)    
                                            
                                        Line 0 ""    
                                }    
     
                                Line 4 "Network performance: " $OPTNetworkPerformanceEnabled    
                                If($OPTNetworkPerformanceEnabled -eq "True")    
                                {    
                                        Line 5 "Network Performance Optimizations"    
                                        Line 0 ""    
                                        Line 6 "Setting                      Enabled  Value"    
                                        Line 6 "==========================================="    
                                        #               123456789012345678901234567SS1234567SS12345    
                                        #               FileNotFoundCacheEntriesMax  False    32768    
                                        Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "FileInfoCacheEntriesMax", `    
                                        $RDSTemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(), `    
                                        $RDSTemplate.Optimization.NetworkPerformance.FileInfoCache)    
                                            
                                        Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "DirectoryCacheEntriesMax", `    
                                        $RDSTemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(), `    
                                        $RDSTemplate.Optimization.NetworkPerformance.DirCacheMax)    
                                            
                                        Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "FileNotFoundCacheEntriesMax", `    
                                        $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(), `    
                                        $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCache)    
                                            
                                        Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "DormantFileLimit", `    
                                        $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(), `    
                                        $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimit)    
                                            
                                        Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "Disable TCP/IP Task Offload", `    
                                        $RDSTemplate.Optimization.NetworkPerformance.DisableTCP.ToString(), `    
                                        "")    
                                            
                                        Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "Disable IPv6 Components", `    
                                        $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(), `    
                                        "")    
                                            
                                        Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "Disable IPv6 to IPv4", `    
                                        $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(), `    
                                        "")    
                                            
                                        Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                        "Disables isatap for IPv6", `    
                                        $RDSTemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString(), `    
                                        "")    
                                            
                                        Line 0 ""    
                                }    
     
                                Line 4 "Registry: " $OPTRegistryEnabled    
                                If($OPTRegistryEnabled -eq "True")    
                                {    
                                        Line 5 "Registry Optimizations"    
                                        Line 0 ""    
                                        #               123456789012345678901234567SS1234567SS12345    
                                        #               FileNotFoundCacheEntriesMax  False    32768    
                                        Line 6 "Registry                                  Action  Value                 Type           Data                  Path                                                        "    
                                        Line 6 "========================================================================================================================================================================="    
                                        #               1234567890123456789012345678901234567890SS123456SS12345678901234567890SS1234567890123SS12345678901234567890SS123456789012345678901234567890123456789012345678901234567890    
                                        #               Increase service startup timeouts         Modify  99999999999999999999  REG_EXPAND_SZ  99999999999999999999  HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Disk    
                                        ForEach($item in $RDSHost.Optimization.Registry.RegistryList)    
                                        {    
                                                If($item.RegType.ToString() -eq "REG_SZ" -or $item.RegType.ToString() -eq "REG_EXPAND_SZ")    
                                                {    
                                                        Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `    
                                                        $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType.ToString(), $item.StringValue, "$($item.HiveType)\$($item.Path)")    
                                                }    
                                                ElseIf($item.RegType.ToString() -eq "REG_DWORD" -or $item.RegType.ToString() -eq "REG_QWORD")    
                                                {    
                                                        Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `    
                                                        $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType.ToString(), $item.DWORDValue, "$($item.HiveType)\$($item.Path)")    
                                                }    
                                                ElseIf($item.RegType.ToString() -eq "REG_MULTI_SZ")    
                                                {    
                                                        #If($item.StringValue.Count -eq 1)    
                                                        #{    
                                                        #       Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `    
                                                        #       $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType.ToString(), $item.StringValue.ToString(), "$($item.HiveType)\$($item.Path)")    
                                                        #}    
                                                        #Else    
                                                        #{    
                                                                $cnt = -1    
                                                                $TmpArray = $item.StringValue.Split("`r")    
                                                                ForEach($SubItem in $TmpArray)    
                                                                {    
                                                                        $cnt++    
                                                                            
                                                                        If($cnt -eq 0)    
                                                                        {    
                                                                                Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `    
                                                                                $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType.ToString(), $SubItem, "$($item.HiveType)\$($item.Path)")    
                                                                        }    
                                                                        Else    
                                                                        {    
                                                                                Line 17 "       " $SubItem    
                                                                        }    
                                                                }    
                                                        #}    
                                                }    
                                        }    
                                        Line 0 ""    
                                }    
     
                                Line 4 "Visual Effects: " $OPTVisualEffectsEnabled    
                                If($OPTVisualEffectsEnabled -eq "True")    
                                {    
                                        Line 5 "Visual Effects Optimizations"    
                                        Line 0 ""    
                                            
                                        Switch ($RDSTemplate.Optimization.VisualEffects.VisualEffectsTypes)    
                                        {    
                                                "LetWindowsChooseWhatsBest"     {$VisualEffectsType = "Let Windows choose what's best"; Break}    
                                                "AdjustForBestAppearnce"        {$VisualEffectsType = "Adjust for best appearance"; Break} #misspelled in the PoSH output and the docs    
                                                "AdjustForBestPerformance"      {$VisualEffectsType = "Adjust for best performance"; Break}    
                                                "Custom"                                        {$VisualEffectsType = "Custom"; Break}    
                                                Default                                         {$VisualEffectsType = "Unable to determine Visual Effects Optimization type: $($RDSTemplate.Optimization.VisualEffects.VisualEffectsTypes)"; Break}    
                                        }    
                                        Line 6 $VisualEffectsType    
                                        Line 0 ""    
                                        Line 6 "Setting                                             Enabled"    
                                        Line 6 "==========================================================="    
                                        #               12345678901234567890123456789012345678901234567890SS1234567    
                                        #               Use drop shadows for icon labels on the desktop     False      
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Animate controls and elements inside windows", `    
                                        $RDSTemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Animate windows when minimizing and maximizing", `    
                                        $RDSTemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Animations in the taskbar", `    
                                        $RDSTemplate.Optimization.VisualEffects.AnimateTaskbar.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Enable Peek", `    
                                        $RDSTemplate.Optimization.VisualEffects.EnablePeek.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Fade or slide menus into view", `    
                                        $RDSTemplate.Optimization.VisualEffects.FadeSlideMenus.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Fade or slide Tooltips into view", `    
                                        $RDSTemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Fade out menu items after clicking", `    
                                        $RDSTemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Save taskbar thumbnail previews", `    
                                        $RDSTemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Show shadows under mouse pointer", `    
                                        $RDSTemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Show shadows under windows", `    
                                        $RDSTemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Show thumbnails instead of icons", `    
                                        $RDSTemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Show translucent selection rectangle", `    
                                        $RDSTemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Show window contents while dragging", `    
                                        $RDSTemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Slide open combo boxes", `    
                                        $RDSTemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Smooth edges of screen fonts", `    
                                        $RDSTemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Smooth-scroll list boxes", `    
                                        $RDSTemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString())    
                                            
                                        Line 6 ( "{0,-50}  {1,-7}" -f `    
                                        "Use drop shadows for icon labels on the desktop", `    
                                        $RDSTemplate.Optimization.VisualEffects.DropShadowsIcon.ToString())    
                                            
                                        Line 0 ""    
                                }    
     
                                Line 4 "Disk cleanup: " $OPTDiskCleanupEnabled    
                                If($OPTDiskCleanupEnabled -eq "True")    
                                {    
                                        Line 5 "Disk Cleanup Optimizations"    
                                        Line 0 ""    
                                            
                                        Line 6 "Setting                            Enabled"    
                                        Line 6 "=========================================="    
                                        #               123456789012345678901234567890123SS1234567    
                                        #               Clean up temporary files and logs  False      
                                        Line 6 ( "{0,-33}  {1,-7}" -f `    
                                        "Clean up redundant system files", `    
                                        $RDSTemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString())    
                                            
                                        Line 6 ( "{0,-33}  {1,-7}" -f `    
                                        "Clean up the WinSxS Folder", `    
                                        $RDSTemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString())    
                                            
                                        Line 6 ( "{0,-33}  {1,-7}" -f `    
                                        "Clean up temporary files and logs", `    
                                        $RDSTemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString())    
                                            
                                        Line 6 ( "{0,-33}  {1,-7}" -f `    
                                        "Remove OneDrive", `    
                                        $RDSTemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString())    
                                            
                                        Line 6 ( "{0,-33}  {1,-7}" -f `    
                                        "Delete users' profiles", `    
                                        $RDSTemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString())    
                                            
                                        Line 0 ""    
                                }    
     
                                Line 4 "Custom script: " $OPTCustomScriptEnabled    
                                If($OPTCustomScriptEnabled  -eq "True")    
                                {    
                                        Line 5 "Custom Script"    
                                        Line 0 ""    
                                            
                                        Line 6 "Command`t`t : " $RDSTemplate.Optimization.CustomScript.Command    
                                        Line 6 "Arguments`t : " $RDSTemplate.Optimization.CustomScript.Arguments    
                                        Line 6 "Initial directory: " $RDSTemplate.Optimization.CustomScript.InitDir    
                                        Line 6 "Username`t : " $RDSTemplate.Optimization.CustomScript.User    
                                        Line 0 ""    
                                }    
 
                                $columnHeaders = @("Inherit default settings:",($Script:htmlsb),$RDSTemplate.InheritDefaultOptimizationSettings.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Date",($Script:htmlsb),$RDSSchedule.StartDateTime.ToShortDateString(),$htmlwhite)
                                $rowdata += @(,("Enable optimization:",($Script:htmlsb), $OPTEnableOptimization,$htmlwhite))    
                                $rowdata += @(,("Optimization type:",($Script:htmlsb), $OPTOptimizationType,$htmlwhite))    
     
                                $msg = "Optimization"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 4 0 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled    
                                If($OPTWindowsDefenderATPEnabled -eq "True")    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Windows Defender ATP Optimizations",($Script:htmlsb),"",$htmlwhite)    
     
                                        If($RDSTemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")    
                                        {    
                                                $rowdata += @(,("     Turn off Windows Defender ATP (I use my own ATP solution)",($Script:htmlsb), "",$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("     Turn on Windows Defender ATP and set process and folder exclusions",($Script:htmlsb), "",$htmlwhite))    
                                                $rowdata += @(,("     Disable real-time protection",($Script:htmlsb), $RDSTemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(),$htmlwhite))    
                                                $rowdata += @(,("",($Script:htmlsb), "",$htmlwhite))    
                                                    
                                                $cnt = -1    
                                                ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeFolders)    
                                                {    
                                                        $cnt++    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $rowdata += @(,("     Exclude files and folders",($Script:htmlsb), $item,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))    
                                                        }    
                                                }    
     
                                                $cnt = -1    
                                                ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)    
                                                {    
                                                        $cnt++    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $rowdata += @(,("     Exclude processes",($Script:htmlsb), $item,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))    
                                                        }    
                                                }    
                                                    
                                                $cnt = -1    
                                                ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeExtension)    
                                                {    
                                                        $cnt++    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $rowdata += @(,("     Exclude extensions",($Script:htmlsb), $item,$htmlwhite))                                   $rowdata += @(,("Start",($Script:htmlsb),$RDSSchedule.StartDateTime.ToShortTimeString(),$htmlwhite))
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))    
                                                        }    
                                                }    
                                        }    
     
     
                                        $msg = ""    
                                        $columnWidths = @("300","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Windows Components: " $OPTWindowsComponentsEnabled    
                                If($OPTWindowsComponentsEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Windows Components Optimizations"    
     
                                        $rowdata = @()    
     
                                        ForEach($item in $RDSTemplate.Optimization.WindowsComponents.WindowsComponentsList)    
                                        {    
                                                $rowdata += @(,(    
                                                        $item.DisplayName,$htmlwhite,    
                                                        $item.ComponentName,$htmlwhite)    
                                                )    
                                        }    
     
                                        $columnHeaders = @(    
                                                "Display Name",($Script:htmlsb),    
                                                "Component",($Script:htmlsb)    
                                        )    
     
                                        $msg = "Disable (remove) components:"    
                                        $columnWidths = @("200","200")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Windows Services: " $OPTWindowsServicesEnabled           
                                If($OPTWindowsServicesEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Windows Services Optimizations"    
     
                                        $rowdata = @()    
     
                                        ForEach($item in $RDSTemplate.Optimization.WindowsServices.WindowsServicesList)    
                                        {    
                                                $rowdata += @(,(    
                                                        $item.DisplayName,$htmlwhite,    
                                                        $item.ServiceName,$htmlwhite,    
                                                        $item.Aliases,$htmlwhite)    
                                                )    
                                        }    
     
                                        $columnHeaders = @(    
                                                "Display Name",($Script:htmlsb),    
                                                "Service",($Script:htmlsb),    
                                                "Aliases",($Script:htmlsb)    
                                        )    
     
                                        $msg = "Disable services:"    
                                        $columnWidths = @("200","100","50")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled    
                                If($OPTWinodwsScheduledTasksEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Windows Scheduled Tasks Optimizations"    
     
                                        $rowdata = @()    
     
                                        ForEach($item in $RDSTemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)    
                                        {    
                                                $rowdata += @(,(    
                                                        $item.Task,$htmlwhite,    
                                                        $item.Type.Tostring(),$htmlwhite,    
                                                        $item.Location,$htmlwhite)    
                                                )    
                                        }    
     
                                        $columnHeaders = @(    
                                                "Task",($Script:htmlsb),    
                                                "Type",($Script:htmlsb),    
                                                "Location",($Script:htmlsb)    
                                        )    
     
                                        $msg = "Disable tasks:"    
                                        $columnWidths = @("200","50","250")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled    
                                If($OPTWindowsAdvancedOptionsEnabled -eq "True")                                   If($Action -eq "Reboot - Drain Mode")
 
                                        WriteHTMLLine 0 0 "Windows Advanced Options" <>  
     
                                        $rowdata = @()    
     
                                        $rowdata += @(,(    
                                                "Disable Hibernate",$htmlwhite,    
                                                $RDSTemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable Telemetry collection",$htmlwhite,    
                                                $RDSTemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable System Restore",$htmlwhite,    
                                                $RDSTemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable error reporting to send additional data",$htmlwhite,    
                                                $RDSTemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable Tiles",$htmlwhite,    
                                                $RDSTemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable Cortana digital assistant",$htmlwhite,    
                                                $RDSTemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Turn off Microsoft consumer experience",$htmlwhite,    
                                                $RDSTemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Do not show Windows tips",$htmlwhite,    
                                                $RDSTemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Remove Common program groups from the Start Menu",$htmlwhite,    
                                                $RDSTemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Partial Start Menu layout",$htmlwhite,    
                                                $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(),$htmlwhite,    
                                                $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent,$htmlwhite)    
                                        )    
     
                                        $columnHeaders = @(    
                                                "Setting",($Script:htmlsb),    
                                                "Enabled",($Script:htmlsb),    
                                                "Value",($Script:htmlsb)    
                                        )    
     
                                        $msg = ""    
                                        $columnWidths = @("300","50","200")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Network performance: " $OPTNetworkPerformanceEnabled    
                                If($OPTWindowsAdvancedOptionsEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Network Performance Optimizations"    
     
                                        $rowdata = @()    
     
                                        $rowdata += @(,(    
                                                "FileInfoCacheEntriesMax",$htmlwhite,    
                                                $RDSTemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(),$htmlwhite,    
                                                $RDSTemplate.Optimization.NetworkPerformance.FileInfoCache,$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "DirectoryCacheEntriesMax",$htmlwhite,    
                                                $RDSTemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(),$htmlwhite,    
                                                $RDSTemplate.Optimization.NetworkPerformance.DirCacheMax,$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "FileNotFoundCacheEntriesMax",$htmlwhite,    
                                                $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(),$htmlwhite,    
                                                $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCache,$htmlwhite)                                           $rowdata += @(,("Complete in",($Script:htmlsb),$TimeDuration,$htmlwhite))
                                        )    
     
                                        $rowdata += @(,(    
                                                "DormantFileLimit",$htmlwhite,    
                                                $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(),$htmlwhite,    
                                                $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimit,$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable TCP/IP Task Offload",$htmlwhite,    
                                                $RDSTemplate.Optimization.NetworkPerformance.DisableTCP.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable IPv6 Components",$htmlwhite,    
                                                $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disable IPv6 to IPv4",$htmlwhite,    
                                                $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Disables isatap for IPv6",$htmlwhite,    
                                                $RDSTemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString(),$htmlwhite,    
                                                "",$htmlwhite)    
                                        )    
     
                                        $columnHeaders = @(    
                                                "Setting",($Script:htmlsb),    
                                                "Enabled",($Script:htmlsb),    
                                                "Value",($Script:htmlsb)    
                                        )    
     
                                        $msg = ""    
                                        $columnWidths = @("170","50","50")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
 
  <>  
                                WriteHTMLLine 4 0 "Registry: " $OPTRegistryEnabled           
                                If($OPTRegistryEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Registry Optimizations"    
     
                                        $rowdata = @()    
     
                                        ForEach($item in $RDSTemplate.Optimization.Registry.RegistryList)    
                                        {    
                                                If($item.RegType.ToString() -eq "REG_SZ" -or $item.RegType.ToString() -eq "REG_EXPAND_SZ")    
                                                {    
                                                        $rowdata += @(,(    
                                                                $item.DisplayName,$htmlwhite,    
                                                                $item.Action,$htmlwhite,    
                                                                $item.RegistryName,$htmlwhite,    
                                                                $item.RegType.ToString(),$htmlwhite,    
                                                                $item.StringValue,$htmlwhite,    
                                                                "$($item.HiveType)\$($item.Path)",$htmlwhite)    
                                                        )    
                                                }    
                                                ElseIf($item.RegType.ToString() -eq "REG_DWORD" -or $item.RegType.ToString() -eq "REG_QWORD")    
                                                {    
                                                        $rowdata += @(,(    
                                                                $item.DisplayName,$htmlwhite,    
                                                                $item.Action,$htmlwhite,    
                                                                $item.RegistryName,$htmlwhite,    
                                                                $item.RegType.ToString(),$htmlwhite,    
                                                                $item.DWORDValue,$htmlwhite,    
                                                                "$($item.HiveType)\$($item.Path)",$htmlwhite)    
                                                        )    
                                                }    
                                                ElseIf($item.RegType.ToString() -eq "REG_MULTI_SZ")    
                                                {    
                                                        $rowdata += @(,(    
                                                                $item.DisplayName,$htmlwhite,    
                                                                $item.Action,$htmlwhite,    
                                                                $item.RegistryName,$htmlwhite,    
                                                                $item.RegType.ToString(),$htmlwhite,    
                                                                $item.StringValue.ToString(),$htmlwhite,    
                                                                "$($item.HiveType)\$($item.Path)",$htmlwhite)    
                                                        )    
                                                }    
                                        }    
     
                                        $columnHeaders = @(    
                                                "Registry",($Script:htmlsb),    
                                                "Action",($Script:htmlsb),    
                                                "Value",($Script:htmlsb),    
                                                "Type",($Script:htmlsb),    
                                                "Data",($Script:htmlsb),    
                                                "Path",($Script:htmlsb)    
                                        )    
     
                                        $msg = ""    
                                        $columnWidths = @("200","50","100","100","100","200")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Visual Effects: " $OPTVisualEffectsEnabled    
                                If($OPTVisualEffectsEnabled -eq "True")                                   ElseIf($Action -eq "Disable")
 
                                        WriteHTMLLine 0 0 "Visual Effects Optimizations" <>  
     
                                        $rowdata = @()    
     
                                        $rowdata += @(,(    
                                                "Animate controls and elements inside windows",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Animate windows when minimizing and maximizing",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Animations in the taskbar",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.AnimateTaskbar.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Enable Peek",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.EnablePeek.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Fade or slide menus into view",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.FadeSlideMenus.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Fade or slide Tooltips into view",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Fade out menu items after clicking",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Save taskbar thumbnail previews",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Show shadows under mouse pointer",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Show shadows under windows",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Show thumbnails instead of icons",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Show translucent selection rectangle",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Show window contents while dragging",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Slide open combo boxes",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Smooth edges of screen fonts",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Smooth-scroll list boxes",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Use drop shadows for icon labels on the desktop",$htmlwhite,    
                                                $RDSTemplate.Optimization.VisualEffects.DropShadowsIcon.ToString(),$htmlwhite)                                           $rowdata += @(,("Duration",($Script:htmlsb),$TimeDuration,$htmlwhite))
                                        )    
     
                                        $columnHeaders = @(    
                                                "Setting",($Script:htmlsb),    
                                                "Enabled",($Script:htmlsb)    
                                        )    
     
                                        $msg = ""    
                                        $columnWidths = @("275","50")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
 
  <>  
                                WriteHTMLLine 4 0 "Disk cleanup: " $OPTDiskCleanupEnabled    
                                If($OPTDiskCleanupEnabled -eq "True")    
                                {    
                                        WriteHTMLLine 0 0 "Disk Cleanup Optimizations"    
     
                                        $rowdata = @()    
     
                                        $rowdata += @(,(    
                                                "Clean up redundant system files",$htmlwhite,    
                                                $RDSTemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Clean up the WinSxS Folder",$htmlwhite,    
                                                $RDSTemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Clean up temporary files and logs",$htmlwhite,    
                                                $RDSTemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Remove OneDrive",$htmlwhite,    
                                                $RDSTemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString(),$htmlwhite)    
                                        )    
     
                                        $rowdata += @(,(    
                                                "Delete users' profiles",$htmlwhite,    
                                                $RDSTemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString(),$htmlwhite)    
                                        )    
     
                                        $columnHeaders = @(    
                                                "Setting",($Script:htmlsb),    
                                                "Enabled",($Script:htmlsb)    
                                        )    
     
                                        $msg = ""    
                                        $columnWidths = @("200","50")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                WriteHTMLLine 4 0 "Custom script: " $OPTCustomScriptEnabled    
                                If($OPTCustomScriptEnabled -eq "True")    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Custom Script",($Script:htmlsb),"",$htmlwhite)    
                                        $rowdata += @(,("     Command",($Script:htmlsb), $RDSTemplate.Optimization.CustomScript.Command,$htmlwhite))    
                                        $rowdata += @(,("     Arguments",($Script:htmlsb), $RDSTemplate.Optimization.CustomScript.Arguments,$htmlwhite))    
                                        $rowdata += @(,("     Initial directory",($Script:htmlsb), $RDSTemplate.Optimization.CustomScript.InitDir,$htmlwhite))    
                                        $rowdata += @(,("     Username",($Script:htmlsb), $RDSTemplate.Optimization.CustomScript.User,$htmlwhite))                                   $rowdata += @(,("Repeat",($Script:htmlsb),$Repeat,$htmlwhite))
 
                                        $msg = "" <>                                 $msg = "Trigger"
                                        $columnWidths = @("125","200")                                   $columnWidths = @("200","275")
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                        WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                                }    
 
                        #License Keys <>                         #Options
 
                                WriteWordLine 4 0 "License Keys" <>                                 WriteWordLine 4 0 "Options"
 
                                Line 2 "License Keys" <>                                 Line 2 "Options"
 
  <>                                 $ScriptInformation.Add(@{Data = "Send message before schedule is triggered"; Value = ""; }) > $Null
                                    
                                    If($RDSSChedule.Messages.Count -gt 0)
                                    {
                                If($RDSTemplate.LicenseKeyType.ToString() -eq "KMS")                                           ForEach($Item in $RDSSChedule.Messages)
                                {                                           {
                                                    Switch ($Item.SendMsgSecs)
                                                    {
                                                            900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}
                                                            1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}
                                                            2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}
                                                            3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}
                                                            7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}
                                                            10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}
                                                            Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}
                                                    }
                                                    
                                                    $ScriptInformation.Add(@{Data = "Enabled"; Value = $Item.Enabled.ToString(); }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Body"; Value = $Item.Message; }) > $Null
                                        $ScriptInformation.Add(@{Data = "License key management type"; Value = "Key Management Service (KMS)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = "Title"; Value = $Item.MessageTitle; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Time"; Value = $MsgTime; }) > $Null
                                            }
 
                                Else <>  
                                    If($Action -ne "Disable")
 
                                        $ScriptInformation.Add(@{Data = "License key management type"; Value = "Multple Activation Key (MAK)"; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Enable Drain Mode"; Value = $RDSSchedule.DrainMode.ToString(); }) > $Null
                                                                           }
                                        $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $RDSTemplate.Id -EA 0 4>$Null                                   If($Action -eq "Reboot - Drain Mode")
                                            
                                        ForEach($Item in $LicenseKeys)    
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "License Key"; Value = $Item.LicenseKey; }) > $Null                                           $ScriptInformation.Add(@{Data = "Force server reboot after"; Value = $ForceRebootTime; }) > $Null
                                                $ScriptInformation.Add(@{Data = "Key Limit"; Value = $Item.KeyLimit; }) > $Null                                   }
                                    If($Action -like "Reboot*")
                                    {
                                            $ScriptInformation.Add(@{Data = "Enforce schedule for currently inactive RD Session Host"; Value = $RDSSchedule.EnforceOnInactive.ToString(); }) > $Null
                                        }                                   }
                                    If($Action -eq "Disable")
                                    {
                                            $ScriptInformation.Add(@{Data = "On disable"; Value = $OnDisable; }) > $Null
 
                                If($RDSTemplate.LicenseKeyType.ToString() -eq "KMS") +-  
                                {    
                                        Line 3 "License key management type: " "Key Management Service (KMS)"    
                                }    
                                Else    
                                {    
                                        Line 3 "License key management type: " "Multple Activation Key (MAK)"    
                                            
                                        $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $RDSTemplate.Id -EA 0 4>$Null    
     
                                        ForEach($Item in $LicenseKeys)    
                                        {    
                                                Line 3 "License Key`t: " $Item.LicenseKey    
                                                Line 3 "Key Limit`t: " $Item.KeyLimit    
                                        }    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                If($RDSTemplate.LicenseKeyType.ToString() -eq "KMS")    
                                {    
                                        $columnHeaders = @("License key management type",($Script:htmlsb),"Key Management Service (KMS)",$htmlwhite)    
                                }    
                                Else    
                                {    
                                        $columnHeaders = @("License key management type",($Script:htmlsb),"Multple Activation Key (MAK)",$htmlwhite)    
                                            
                                        $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $RDSTemplate.Id -EA 0 4>$Null    
     
                                        $cnt = -1    
                                        ForEach($Item in $LicenseKeys)    
                                        {    
                                                $rowdata += @(,("License Key",($Script:htmlsb),$Item.LicenseKey,$htmlwhite))    
                                                $rowdata += @(,("Key Limit",($Script:htmlsb),$Item.KeyLimit,$htmlwhite))    
                                        }    
                                }    
     
                                $msg = "License Keys"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                }    
        }    
            
        Write-Verbose "$(Get-Date -Format G): `tOutput RD Session Hosts Scheduler"    
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Scheduler"    
        }    
        If($Text)    
        {    
                Line 1 "Scheduler"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Scheduler"    
        }    
     
        $RDSSchedules = Get-RASRDSSchedule -Siteid $Site.Id -EA 0 4> $Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve RD Session Hosts Scheduler for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve RD Session Hosts Scheduler for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve RD Session Hosts Scheduler for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve RD Session Hosts Scheduler for Site $($Site.Name)"    
                }    
        }    
        ElseIf($? -and $Null -eq $RDSSchedules)    
        {    
                Write-Host "    
        No RD Session Host Scheduler retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)"    
                }    
        }    
        Else    
        {    
                ForEach($RDSSchedule in $RDSSchedules)    
                {    
                        $Action = $RDSSchedule.Action    
                        If($RDSSChedule.Action -eq "Reboot")    
                        {    
                                If($RDSSchedule.DrainMode)    
                                {    
                                        $Action = "Reboot - Drain Mode"    
                                }    
                                Else    
                                {    
                                        $Action = "Reboot"    
                                }    
                        }    
     
                        If($Action -eq "Reboot - Drain Mode")    
                        {    
                                If(validObject $RDSSchedule CompleteRebootInSecs)    
                                {    
                                        Switch ($RDSSchedule.CompleteRebootInSecs)    
                                        {    
                                                600             {$TimeDuration = "10 minutes"; Break}    
                                                900             {$TimeDuration = "15 minutes"; Break}    
                                                1800    {$TimeDuration = "30 minutes"; Break}    
                                                2700    {$TimeDuration = "45 minutes"; Break}    
                                                3600    {$TimeDuration = "1 hour"; Break}    
                                                7200    {$TimeDuration = "2 hours"; Break}    
                                                10800   {$TimeDuration = "3 hours"; Break}    
                                                Default {$TimeDuration = "Unable to determine Complete in seconds: $($RDSSchedule.CompleteRebootInSecs)"; Break}    
                                        }    
                                }    
                                Else    
                                {    
                                        $TimeDuration = ""    
                                }    
                                    
                                If(validObject $RDSSchedule ForceRebootAfterSecs)    
                                {    
                                        Switch ($RDSSchedule.ForceRebootAfterSecs)    
                                        {    
                                                900             {$ForceRebootTime = "15 minutes"; Break}    
                                                1800    {$ForceRebootTime = "30 minutes"; Break}    
                                                2700    {$ForceRebootTime = "45 minutes"; Break}    
                                                3600    {$ForceRebootTime = "1 hour"; Break}    
                                                7200    {$ForceRebootTime = "2 hours"; Break}    
                                                10800   {$ForceRebootTime = "3 hours"; Break}    
                                                21600   {$ForceRebootTime = "6 hours"; Break}    
                                                43200   {$ForceRebootTime = "12 hours"; Break}    
                                                86400   {$ForceRebootTime = "1 day"; Break}    
                                                Default {$ForceRebootTime = "Unable to determine Force reboot after seconds: $($RDSSchedule.ForceRebootAfterSecs)"; Break}    
                                        }    
                                }    
                                Else    
                                {    
                                        $ForceRebootTime = ""    
                                }    
                        }    
                            
                        Switch ($RDSSchedule.Repeat)    
                        {    
                                Never                   {$Repeat = "Never "; Break}    
                                EveryDay                {$Repeat = "Every day"; Break}    
                                EveryWeek               {$Repeat = "Every week"; Break}    
                                Every2Weeks             {$Repeat = "Every 2 weeks"; Break}    
                                EveryMonth              {$Repeat = "Every month"; Break}    
                                EveryYear               {$Repeat = "Every year"; Break}    
                                SpecificDays    {$Repeat = "Every $($RDSSchedule.SpecificDays)"; Break}    
                                Default                 {$Repeat = "Unable to determine the Repeat: $($RDSSchedule.Repeat)"; Break}    
                        }    
                            
                        $Target = @()    
                        If($RDSSchedule.TargetType -eq "Server")    
                        {    
                                ForEach($Item in $RDSSchedule.TargetIds)    
                                {    
                                        $Result = Get-RASRDS -Id $Item -EA 0 4>$Null    
                                            
                                        If($? -and $Null -ne $Result)    
                                        {    
                                                $Target += $Result.Server    
                                        }    
                                        Else    
                                        {    
                                                Target += "Unable to find RDS Server for ID $($Item)"    
                                        }    
                                }    
                        }    
                        ElseIf($RDSSchedule.TargetType -eq "ServerGroup")    
                        {    
                                ForEach($Item in $RDSSchedule.TargetIds)    
                                {    
                                        $Result = Get-RASRDSGroup -Id $Item -EA 0 4>$Null    
                                            
                                        If($? -and $Null -ne $Result)    
                                        {    
                                                $Target += $Result.Name    
                                        }    
                                        Else    
                                        {    
                                                Target += "Unable to find RDS Server Group for ID $($Item)"    
                                        }    
                                }    
                        }    
                        Else    
                        {    
                                Target += "Unable to determine Target for TargetType: $($RDSSchedule.TargetType)"    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 3 0 "Schedule Name $($RDSSchedule.Name)"    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $RDSSchedule.Name; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Action"; Value = $Action; }) > $Null    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Target"; Value = $Item; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                    
                                $ScriptInformation.Add(@{Data = "Start"; Value = $RDSSchedule.StartDateTime; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Repeat"; Value = $Repeat; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $RDSSchedule.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $RDSSchedule.AdminLastMod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $RDSSchedule.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $RDSSchedule.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $RDSSchedule.TimeCreate.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "ID"; Value = $RDSSchedule.Id.ToString(); }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 250;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Name`t`t`t: " $RDSSchedule.Name    
                                Line 2 "Action`t`t`t: " $Action    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                Line 2 "Target`t`t`t: " $Item    
                                        }    
                                        Else    
                                        {    
                                                Line 6 "  " $Item    
                                        }    
                                }    
                                    
                                Line 2 "Start`t`t`t: " $RDSSchedule.StartDateTime    
                                Line 2 "Repeat`t`t`t: " $Repeat    
                                Line 2 "Description`t`t: " $RDSSchedule.Description    
                                Line 2 "Last modification by`t: " $RDSSchedule.AdminLastMod    
                                Line 2 "Modified on`t`t: " $RDSSchedule.TimeLastMod.ToString()    
                                Line 2 "Created by`t`t: " $RDSSchedule.AdminCreate    
                                Line 2 "Created on`t`t: " $RDSSchedule.TimeCreate.ToString()    
                                Line 2 "ID`t`t`t: " $RDSSchedule.Id.ToString()    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 3 0 "Schedule Name $($RDSSchedule.Name)"    
                                $rowdata = @()    
                                $columnHeaders = @("Name",($Script:htmlsb),$RDSSchedule.Name,$htmlwhite)    
                                $rowdata += @(,("Action",($Script:htmlsb),$Action,$htmlwhite))    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Target",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                    
                                $rowdata += @(,("Start",($Script:htmlsb),$RDSSchedule.StartDateTime,$htmlwhite))    
                                $rowdata += @(,("Repeat",($Script:htmlsb),$Repeat,$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$RDSSchedule.Description,$htmlwhite))    
                                $rowdata += @(,("Last modification by",($Script:htmlsb),$RDSSchedule.AdminLastMod,$htmlwhite))    
                                $rowdata += @(,("Modified on",($Script:htmlsb),$RDSSchedule.TimeLastMod.ToString(),$htmlwhite))    
                                $rowdata += @(,("Created by",($Script:htmlsb),$RDSSchedule.AdminCreate,$htmlwhite))    
                                $rowdata += @(,("Created on",($Script:htmlsb),$RDSSchedule.TimeCreate.ToString(),$htmlwhite))    
                                $rowdata += @(,("ID",($Script:htmlsb),$RDSSchedule.Id.ToString(),$htmlwhite))    
     
                                $msg = ""    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
                        #Properties    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "General"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "General"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Enable Schedule"; Value = $RDSSchedule.Enabled.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $RDSSchedule.Name; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Action"; Value = $Action; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $RDSSchedule.Description; }) > $Null    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Target"; Value = $Item; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Enable Schedule`t`t`t: " $RDSSchedule.Enabled.ToString()    
                                Line 3 "Name`t`t`t`t: " $RDSSchedule.Name    
                                Line 3 "Action`t`t`t`t: " $Action    
                                Line 3 "Description`t`t`t: " $RDSSchedule.Description    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                Line 3 "Target`t`t`t`t: " $Item    
                                        }    
                                        Else    
                                        {    
                                                Line 7 "  " $Item    
                                        }    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Enable schedule",($Script:htmlsb),$RDSSchedule.Enabled.ToString(),$htmlwhite)    
                                $rowdata += @(,("Name",($Script:htmlsb),$RDSSchedule.Name,$htmlwhite))    
                                $rowdata += @(,("Action",($Script:htmlsb),$Action,$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$RDSSchedule.Description,$htmlwhite))    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Target",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                    
                                $msg = "General"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Trigger    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Trigger"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Trigger"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Date"; Value = $RDSSchedule.StartDateTime.ToShortDateString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start"; Value = $RDSSchedule.StartDateTime.ToShortTimeString(); }) > $Null    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Complete in"; Value = $TimeDuration  ; }) > $Null    
                                }    
                                ElseIf($Action -eq "Disable")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Duration"; Value = $TimeDuration; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "Recur"; Value = $Repeat; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Date`t`t`t`t: " $RDSSchedule.StartDateTime.ToShortDateString()    
                                Line 3 "Start`t`t`t`t: " $RDSSchedule.StartDateTime.ToShortTimeString()    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        Line 3 "Complete in`t`t`t: " $TimeDuration    
                                }    
                                ElseIf($Action -eq "Disable")    
                                {    
                                        Line 3 "Duration`t`t`t: " $TimeDuration    
                                }    
                                Line 3 "Recur`t`t`t`t: " $Repeat    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Date",($Script:htmlsb),$RDSSchedule.StartDateTime.ToShortDateString(),$htmlwhite)    
                                $rowdata += @(,("Start",($Script:htmlsb),$RDSSchedule.StartDateTime.ToShortTimeString(),$htmlwhite))    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        $rowdata += @(,("Complete in",($Script:htmlsb),$TimeDuration,$htmlwhite))    
                                }    
                                ElseIf($Action -eq "Disable")    
                                {    
                                        $rowdata += @(,("Duration",($Script:htmlsb),$TimeDuration,$htmlwhite))    
                                }    
                                $rowdata += @(,("Recur",($Script:htmlsb),$Repeat,$htmlwhite))    
     
                                $msg = "Trigger"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Options    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Options"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Options"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Send message before schedule is triggered"; Value = ""; }) > $Null    
     
                                If($RDSSChedule.Messages.Count -gt 0)    
                                {    
                                        ForEach($Item in $RDSSChedule.Messages)    
                                        {    
                                                Switch ($Item.SendMsgSecs)    
                                                {    
                                                        900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}    
                                                        1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}    
                                                        2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}    
                                                        3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}    
                                                        7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}    
                                                        10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}    
                                                        Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}    
                                                }    
                                                    
                                                $ScriptInformation.Add(@{Data = "Enabled"; Value = $Item.Enabled.ToString(); }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Body"; Value = $Item.Message; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Title"; Value = $Item.MessageTitle; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Time"; Value = $MsgTime; }) > $Null    
                                        }    
                                }    
     
                                If($Action -ne "Disable")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Enable Drain Mode"; Value = $RDSSchedule.DrainMode.ToString(); }) > $Null    
                                }    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Force server reboot after"; Value = $ForceRebootTime; }) > $Null    
                                }    
                                If($Action -like "Reboot*")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Enforce schedule for currently inactive RD Session Host"; Value = $RDSSchedule.EnforceOnInactive.ToString(); }) > $Null    
                                }    
                                If($Action -eq "Disable")    
                                {    
                                        $ScriptInformation.Add(@{Data = "On disable"; Value = $OnDisable; }) > $Null    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
 
        #VDI +-  
        Write-Verbose "$(Get-Date -Format G): Output VDI"    
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "VDI"    
        }    
        If($Text)    
        {    
                Line 1 "VDI"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "VDI"    
        }    
     
 
        No VDI retrieved for Site $($Site.Name).` <>                 No VDI retrieved for Site $($Site.Name).`
 
  <>                 If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 "VDI"
                    }
                    If($Text)
                    {
                            Line 1 "VDI"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "VDI"
                    }
     
                Write-Verbose "$(Get-Date -Format G): `tOutput VDI Pools"                   Write-Verbose "$(Get-Date -Format G): `t`tOutput VDI"
                    ForEach($VDIHost in $VDIHosts)
                #Pools                   {
                            $VDIHostStatus = Get-RASProviderStatus -Id $VDIHost.Id -EA 0 4>$Null
                                          
                            If(!$?)
                            {
                                    Write-Warning "
                                    `n
                                    Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)`
                                    "
                If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                {                                   {
                        $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null                                           WriteWordLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)"
                        If($? -and $Null -ne $VDIPools)                                   }
                                    If($Text)
                        {                                   {
                                ForEach($VDIPool in $VDIPools)                                           Line 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)"
                                    }
                                    If($HTML)
 
                                        WriteWordLine 3 0 "Pool $($VDIPool.Name)" <>                                         WriteHTMLLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)"
                                    }
                                        $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null     
                                                                   }
                                        If($? -and $Null -ne $VDIPoolMembers)                           ElseIf($? -and $Null -eq $VDIHostStatus)
                                        {                           {
                                                $VDIPoolMember = $VDIPoolMembers[0]                                   Write-Host "
                                                Switch($VDIPoolMember.Type)                                   No VDI Host Status retrieved for VDI Host $($VDIHost.Id)`
                                    " -ForegroundColor White
                                    If($MSWord -or $PDF)
                                                {                                   {
                                                        "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}                                           WriteWordLine 0 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)"
                                                        "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}                                   }
                                                        "Desktop"                               {$MemberType = "Guest"; Break}                                   If($Text)
                                                        "GUEST"                                 {$MemberType = "Guest"; Break}                                   {
                                                        "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}                                           Line 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)"
                                                        "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}                                   }
                                                        "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}                                   If($HTML)
                                                        "UNKNOWN"                               {$MemberType = "Unknown"; Break}                                   {
                                                        Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}                                           WriteHTMLLine 0 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)"
                                                }                                   }
                                        }                           }
                                        Else                           Else
                                        {                           {
                                                $MemberType = ""                                   $FullProviderStatus = GetRASStatus $VDIHostStatus.AgentState
     
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 3 0 "Providers"
                                        }                                   }
                                    If($Text)
                                    {
                                            Line 2 "Providers"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 3 0 "Providers"
                                    }
 
  -+                                 $VDIType = GetVDIType $VDIHost.Type
                                    
                                    If($MSWord -or $PDF)
                                    {
 
  <>                                         $ScriptInformation.Add(@{Data = "Provider"; Value = $VDIHost.Server; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $VDIPool.Name; }) > $Null                                           $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null
                                            $ScriptInformation.Add(@{Data = "VDI Agent"; Value = $VDIHost.VDIAgent; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Enabled"; Value = $VDIPool.Enabled.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Status"; Value = $FullProviderStatus; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Direct address"; Value = $VDIHost.DirectAddress; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $VDIPool.Description; }) > $Null                                           $ScriptInformation.Add(@{Data = "Description"; Value = $VDIHost.Description; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Members type"; Value = $MemberType; }) > $Null                                           $ScriptInformation.Add(@{Data = "Log level"; Value = $VDIHostStatus.LogLevel; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $VDIPool.AdminLastMod; }) > $Null                                           $ScriptInformation.Add(@{Data = "Last modification by"; Value = $VDIHost.AdminLastMod; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $VDIPool.TimeLastMod.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Modified on"; Value = $VDIHost.TimeLastMod.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $VDIPool.AdminCreate; }) > $Null                                           $ScriptInformation.Add(@{Data = "Created by"; Value = $VDIHost.AdminCreate; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $VDIPool.TimeCreate.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Created on"; Value = $VDIHost.TimeCreate.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "ID"; Value = $VDIHost.Id.ToString(); }) > $Null
                                            
 
  <>                                 }
                                    If($Text)
                                    {
                                            Line 3 "Provider`t`t: " $VDIHost.Server
                                            Line 3 "Type`t`t`t: " $VDIType
                                            Line 3 "VDI Agent`t`t: " $VDIHost.VDIAgent
                                            Line 3 "Status`t`t`t: " $FullProviderStatus
                                            Line 3 "Direct address`t`t: " $VDIHost.DirectAddress
                                            Line 3 "Description`t`t: " $VDIHost.Description
                                            Line 3 "Log level`t`t: " $VDIHostStatus.LogLevel
                                            Line 3 "Last modification by`t: " $VDIHost.AdminLastMod
                                            Line 3 "Modified on`t`t: " $VDIHost.TimeLastMod.ToString()
                                            Line 3 "Created by`t`t: " $VDIHost.AdminCreate
                                            Line 3 "Created on`t`t: " $VDIHost.TimeCreate.ToString()
                                            Line 3 "ID`t`t`t: " $VDIHost.Id.ToString()
                                            Line 0 ""
                                    }
                                    If($HTML)
                                    {
                                            $rowdata = @()
                                            $columnHeaders = @("Provider",($Script:htmlsb),$VDIHost.Server,$htmlwhite)
                                            $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))
                                            $rowdata += @(,("VDI Agent",($Script:htmlsb),$VDIHost.VDIAgent,$htmlwhite))
                                            $rowdata += @(,("Status",($Script:htmlsb),$FullProviderStatus,$htmlwhite))
                                            $rowdata += @(,("Direct address",($Script:htmlsb),$VDIHost.DirectAddress,$htmlwhite))
                                            $rowdata += @(,("Description",($Script:htmlsb),$VDIHost.Description,$htmlwhite))
                                            $rowdata += @(,("Log level",($Script:htmlsb),$VDIHostStatus.LogLevel,$htmlwhite))
                                            $rowdata += @(,("Last modification by",($Script:htmlsb), $VDIHost.AdminLastMod,$htmlwhite))
                                            $rowdata += @(,("Modified on",($Script:htmlsb), $VDIHost.TimeLastMod.ToString(),$htmlwhite))
                                            $rowdata += @(,("Created by",($Script:htmlsb), $VDIHost.AdminCreate,$htmlwhite))
                                            $rowdata += @(,("Created on",($Script:htmlsb), $VDIHost.TimeCreate.ToString(),$htmlwhite))
                                            $rowdata += @(,("Id",($Script:htmlsb),$VDIHost.Id.ToString(),$htmlwhite))
     
                                            $msg = ""
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
                            }
                                                                  
                                        #General                           #General
                                                                  
                            If($MSWord -or $PDF)
                            {
                                        WriteWordLine 4 0 "General"                                   WriteWordLine 4 0 "General"
                            }
                            If($Text)
                            {
                                    Line 3 "General"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            $HostPA = Get-RASPA -Id $VDIHost.PreferredPAId -EA 0 4>$Null
                            
                            If($? -and -$Null -ne $HostPA)
                            {
                                    If($VDIHost.VDIAgent -eq $HostPa.Server)
                                    {
                                            $DedicatedVDIAgent = $False
                                    }
                                    Else
                                    {
                                            $DedicatedVDIAgent = $True
                                    }
                            }
                            ElseIf($? -and $Null -eq $HostPA)
                            {
                                    $DedicatedVDIAgent = $False
                            }
                            Else
                            {
                                    $DedicatedVDIAgent = $False
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                        $ScriptInformation.Add(@{Data = "Enable pool in site"; Value = $VDIPool.Enabled.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable provider in site"; Value = $VDIHost.Enabled.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null
                                    If($VDIType -eq "Azure")
                                    {
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $VDIPool.Name; }) > $Null                                           $ScriptInformation.Add(@{Data = "Name"; Value = $VDIHost.Server; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $VDIPool.Description; }) > $Null                                           $ScriptInformation.Add(@{Data = "Description"; Value = $VDIHost.Description; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Subscription details"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Authentication URL"; Value = $VDIHost.AzureInfo.AuthenticationURL; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Management URL"; Value = $VDIHost.AzureInfo.ManagementURL; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Resource URI"; Value = $VDIHost.AzureInfo.ResourceURI; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Tenant ID"; Value = $VDIHost.AzureInfo.TenantID; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Subscription ID"; Value = $VDIHost.AzureInfo.SubscriptionID; }) > $Null
                                    }
                                    Else
                                    {
                                            $ScriptInformation.Add(@{Data = "Host"; Value = $VDIHost.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Port"; Value = $VDIHost.VDIPort.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Description"; Value = $VDIHost.Description; }) > $Null
                                    }
                                    $ScriptInformation.Add(@{Data = "Dedicated VDI Agent"; Value = $DedicatedVDIAgent.ToString(); }) > $Null
                                    If($DedicatedVDIAgent)
                                    {
                                            $ScriptInformation.Add(@{Data = "Agent address"; Value = $VDIHost.VDIAgent; }) > $Null
                                    }
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `                                   $Table = AddWordTable -Hashtable $ScriptInformation `
                                        -Columns Data,Value `                                   -Columns Data,Value `
                                        -List `                                   -List `
                                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                                        $Table = $Null                                   $Table = $Null
                                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 4 "Enable provider in site`t`t: " $VDIHost.Enabled.ToString()
                                    Line 4 "Type`t`t`t`t: " $VDIType
                                    If($VDIType -eq "Azure")
                                    {
                                            Line 4 "Name`t`t`t`t: " $VDIHost.Server
                                            Line 4 "Description`t`t`t: " $VDIHost.Description
                                            Line 4 "Subscription details`t`t: " 
                                            Line 5 "Authentication URL: " $VDIHost.AzureInfo.AuthenticationURL
                                            Line 5 "Management URL`t  : " $VDIHost.AzureInfo.ManagementURL
                                            Line 5 "Resource URI`t  : " $VDIHost.AzureInfo.ResourceURI
                                            Line 4 "Tenant ID`t`t`t: " $VDIHost.AzureInfo.TenantID
                                            Line 4 "Subscription ID`t`t`t: " $VDIHost.AzureInfo.SubscriptionID
                                    }
                                    Else
                                    {
                                            Line 4 "Host`t`t`t`t: " $VDIHost.Server
                                            Line 4 "Port`t`t`t`t: " $VDIHost.VDIPort.ToString()
                                            Line 4 "Description`t`t`t: " $VDIHost.Description
                                    }
                                    Line 4 "Dedicated VDI Agent`t`t: " $DedicatedVDIAgent.ToString()
                                    If($DedicatedVDIAgent)
                                    {
                                            Line 4 "Agent address`t`t`t: " $VDIHost.VDIAgent
                                    }
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Enable provider in site",($Script:htmlsb),$VDIHost.Enabled.ToString(),$htmlwhite)
                                    $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))
                                    If($VDIType -eq "Azure")
                                    {
                                            $rowdata += @(,( "Name",($Script:htmlsb), $VDIHost.Server,$htmlwhite))
                                            $rowdata += @(,( "Description",($Script:htmlsb), $VDIHost.Description,$htmlwhite))
                                            $rowdata += @(,( "Subscription details",($Script:htmlsb), "",$htmlwhite))
                                            $rowdata += @(,( "     Authentication URL",($Script:htmlsb), $VDIHost.AzureInfo.AuthenticationURL,$htmlwhite))
                                            $rowdata += @(,( "     Management URL",($Script:htmlsb), $VDIHost.AzureInfo.ManagementURL,$htmlwhite))
                                            $rowdata += @(,( "     Resource URI",($Script:htmlsb), $VDIHost.AzureInfo.ResourceURI,$htmlwhite))
                                            $rowdata += @(,( "Tenant ID",($Script:htmlsb), $VDIHost.AzureInfo.TenantID,$htmlwhite))
                                            $rowdata += @(,( "Subscription ID",($Script:htmlsb), $VDIHost.AzureInfo.SubscriptionID,$htmlwhite))
                                    }
                                    Else
                                    {
                                            $rowdata += @(,("Host",($Script:htmlsb),$VDIHost.Server,$htmlwhite))
                                            $rowdata += @(,("Port",($Script:htmlsb),$VDIHost.VDIPort.ToString(),$htmlwhite))
                                            $rowdata += @(,("Description",($Script:htmlsb),$VDIHost.Description,$htmlwhite))
                                    }
                                    $rowdata += @(,("Dedicated VDI Agent",($Script:htmlsb),$DedicatedVDIAgent.ToString(),$htmlwhite))
                                    If($DedicatedVDIAgent)
                                    {
                                            $rowdata += @(,("Agent address",($Script:htmlsb),$VDIHost.VDIAgent,$htmlwhite))
                                    }
     
                                    $msg = "General"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                                                                  
                                        #Members                           #Credentials
                                                                  
                            If($MSWord -or $PDF)
                            {
                                        WriteWordLine 4 0 "Members"                                   WriteWordLine 4 0 "Credentials"
                            }
                            If($Text)
                            {
                                    Line 3 "Credentials"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                        If($VDIPool.Members.Count -eq 0)                                   If($VDIType -eq "Azure")
                                        {                                   {
                                            $ScriptInformation.Add(@{Data = "Application ID"; Value = $VDIHost.VDIUsername; }) > $Null
                                    }
                                    Else
                                    {
                                                $ScriptInformation.Add(@{Data = "Members"; Value = "There are no pool members"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Username"; Value = $VDIHost.VDIUsername; }) > $Null
                                        }                                   }
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    If($VDIType -eq "Azure")
                                    {
                                            Line 4 "Application ID: " $VDIHost.VDIUsername
                                    }
                                        Else                                   Else
                                        {                                   {
                                            Line 4 "Username`t`t`t: " $VDIHost.VDIUsername
                                    }
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    If($VDIType -eq "Azure")
                                    {
                                            $columnHeaders = @("Application ID",($Script:htmlsb),$VDIHost.VDIUsername,$htmlwhite)
                                    }
                                    Else
                                    {
                                            $columnHeaders = @("Username",($Script:htmlsb),$VDIHost.VDIUsername,$htmlwhite)
                                    }
     
                                    $msg = "Credentials"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            #Agent Settings
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Agent settings"
                            }
                            If($Text)
                            {
                                    Line 3 "Agent settings"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            <#Switch ($VDIHost.DragAndDropMode)
                            {
                                    "Bidirectional"         {$VDIHostDragAndDrop = "Bidirectional"; Break}
                                    "Disabled"                      {$VDIHostDragAndDrop = "Disabled"; Break}
                                    "ClientToServer"        {$VDIHostDragAndDrop = "Client to server only"; Break}
                                    "ServerToClient"        {$VDIHostDragAndDrop = "Server to client only"; Break}
                                    Default                         {$VDIHostDragAndDrop = "Unable to determine Drag and drop: $($VDIHost.DragAndDropMode)"; Break}
                            }#>
     
                            Switch ($VDIHost.FileTransferMode)
                            {
                                    "Bidirectional"         {$VDIHostFileTransferMode = "Bidirectional"; Break}
                                    "Disabled"                      {$VDIHostFileTransferMode = "Disabled"; Break}
                                    "ClientToServer"        {$VDIHostFileTransferMode = "Client to server only"; Break}
                                    "ServerToClient"        {$VDIHostFileTransferMode = "Server to client only"; Break}
                                    Default                         {$VDIHostFileTransferMode = "Unable to determine File Transfer mode: $($VDIHost.FileTransferMode)"; Break}
                            }
     
                            If($VDIHost.FileTransferLocation -eq "")
                            {
                                    $VDIHostFileTransferLocation = "Default download location"
                            }
                            Else
                            {
                                    $VDIHostFileTransferLocation = $VDIHostHost.FileTransferLocation
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Allow Client URL/Mail Redirection"; Value = $VDIHost.AllowURLAndMailRedirection.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Support Windows Shell URL namespace objects"; Value = $VDIHost.SupportShellURLNamespaceObjects.ToString(); }) > $Null
                                    #$ScriptInformation.Add(@{Data = "Drag and drop"; Value = $VDIHostDragAndDrop; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Preferred Publishing Agent"; Value = $VDIHostStatus.PreferredPA; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Allow file transfer command (HTML5 and Chrome clients)"; Value = $VDIHost.AllowFileTransfer.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Configure File Transfer"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Direction"; Value = $VDIHostFileTransferMode; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Location"; Value = $VDIHostFileTransferLocation; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Do not allow to change location"; Value = $VDIHost.FileTransferLockLocation.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Enable drive redirection cache"; Value = $VDIHost.EnableDriveRedirectionCache.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 4 "Allow Client URL/Mail Redirection`t`t`t: " $VDIHost.AllowURLAndMailRedirection.ToString()
                                    Line 4 "Support Windows Shell URL namespace objects`t`t: " $VDIHost.SupportShellURLNamespaceObjects.ToString()
                                    #Line 4 "Drag and drop`t`t`t`t`t`t: " $VDIHostDragAndDrop
                                    Line 4 "Preferred Publishing Agent`t`t`t`t: " $VDIHostStatus.PreferredPA
                                    Line 4 "Allow file transfer command (HTML5 and Chrome clients)`t: " $VDIHost.AllowFileTransfer.ToString()
                                    Line 4 "Configure File Transfer"
                                    Line 5 "Direction`t`t`t: " $VDIHostFileTransferMode
                                    Line 5 "Location`t`t`t: " $VDIHostFileTransferLocation
                                    Line 5 "Do not allow to change location`t: " $VDIHost.FileTransferLockLocation.ToString()
                                    Line 4 "Enable drive redirection cache`t`t`t`t: " $VDIHost.EnableDriveRedirectionCache.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Allow Client URL/Mail Redirection",($Script:htmlsb),$VDIHost.AllowURLAndMailRedirection.ToString(),$htmlwhite)
                                    $rowdata += @(,("Support Windows Shell URL namespace objects",($Script:htmlsb),$VDIHost.SupportShellURLNamespaceObjects.ToString(),$htmlwhite))
                                    #$rowdata += @(,("Drag and drop",($Script:htmlsb),$VDIHostDragAndDrop,$htmlwhite))
                                    $rowdata += @(,("Preferred Publishing Agent",($Script:htmlsb),$VDIHostStatus.PreferredPA,$htmlwhite))
                                    $rowdata += @(,("Allow file transfer command (HTML5 and Chrome clients)",($Script:htmlsb),$VDIHost.AllowFileTransfer.ToString(),$htmlwhite))
                                    $rowdata += @(,("Configure File Transfer",($Script:htmlsb),"",$htmlwhite))
                                    $rowdata += @(,("     Direction",($Script:htmlsb),$VDIHostFileTransferMode,$htmlwhite))
                                    $rowdata += @(,("     Location",($Script:htmlsb),$VDIHostFileTransferLocation,$htmlwhite))
                                    $rowdata += @(,("     Do not allow to change location",($Script:htmlsb),$VDIHost.FileTransferLockLocation.ToString(),$htmlwhite))
                                    $rowdata += @(,("Enable drive redirection cache",($Script:htmlsb),$VDIHost.EnableDriveRedirectionCache.ToString(),$htmlwhite))
     
                                    $msg = "Agent settings"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            #RDP Printer
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "RDP printer"
                            }
                            If($Text)
                            {
                                    Line 3 "RDP printer"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            Switch ($VDIHost.PrinterNameFormat)
                            {
                                    "PrnFormat_PRN_CMP_SES" {$VDIPrinterNameFormat = "Printername (from Computername) in Session no."; Break}
                                    "PrnFormat_SES_CMP_PRN" {$VDIPrinterNameFormat = "Session no. (Computername from) Printername"; Break}
                                    "PrnFormat_PRN_REDSES"  {$VDIPrinterNameFormat = "Printername (redirected Session no.)"; Break}
                                    Default                                 {$VDIPrinterNameFormat = "Unable to determine RDP Printer Name Format: $($VDIHost.PrinterNameFormat)"; Break}
                            }
                            
                            $VDIRemoveSessionNumberFromPrinter = $VDIHost.RemoveSessionNumberFromPrinterName.ToString()
     
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "RDP Printer Name Format"; Value = $VDIPrinterNameFormat; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Remove session number from printer name"; Value = $VDIRemoveSessionNumberFromPrinter; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 4 "RDP Printer Name Format`t`t`t`t: " $VDIPrinterNameFormat
                                    Line 4 "Remove session number from printer name`t`t: " $VDIRemoveSessionNumberFromPrinter
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("RDP Printer Name Format",($Script:htmlsb),$VDIPrinterNameFormat,$htmlwhite)
                                    $rowdata += @(,("Remove session number from printer name",($Script:htmlsb),$VDIRemoveSessionNumberFromPrinter,$htmlwhite))
     
                                    $msg = "RDP printer"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
                    
                    #Pools
                    
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 3 0 "Pools"
                    }
                    If($Text)
                    {
                            Line 2 "Pools"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 3 0 "Pools"
                    }
                    
                    If($MSWord -or $PDF)
                    {
                            $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null
                            If($? -and $Null -ne $VDIPools)
                            {
                                    ForEach($VDIPool in $VDIPools)
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Pools"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "  Name"; Value = $VDIPool.Name; }) > $Null
                                            $ScriptInformation.Add(@{Data = "  Last modification by"; Value = $VDIPool.AdminLastMod; }) > $Null
                                            $ScriptInformation.Add(@{Data = "  Modified on"; Value = $VDIPool.TimeLastMod.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "  Created by"; Value = $VDIPool.AdminCreate; }) > $Null
                                            $ScriptInformation.Add(@{Data = "  Created on"; Value = $VDIPool.TimeCreate.ToString(); }) > $Null
                                            
                                                ForEach($Item in $VDIPool.Members)                                           ForEach($Item in $VDIPool.Members)
                                                {                                           {
                                                        $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null                                                   $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null
                                                                                                          
                                                        If($? -and $Null -ne $VDIPoolMembers)                                                   If($? -and $Null -ne $VDIPoolMembers)
                                                        {                                                   {
                                                            $cnt = -1
                                                                ForEach($VDIPoolMember in $VDIPoolMembers)                                                           ForEach($VDIPoolMember in $VDIPoolMembers)
                                                                {                                                           {
                                                                        Switch($VDIPoolMember.Type)                                                                   Switch($VDIPoolMember.Type)
                                                                        {                                                                   {
                                                                                "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}                                                                           "ALLGUESTINHOST"                {$MemberType = "All Guest VMs in Host"; Break}
                                                                                "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}                                                                           "ALLGUESTSONPROVIDER"   {$MemberType = "All Guest VMs on Provider"; Break}
                                                                                "Desktop"                               {$MemberType = "Guest"; Break}    
                                                                                "GUEST"                                 {$MemberType = "Guest"; Break}                                                                           "GUEST"                                 {$MemberType = "Guest VM"; Break}
                                                                                "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}                                                                           "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                                                "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}    
                                                                                "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}                                                                           "TEMPLATEGUEST"                 {$MemberType = "Template"; Break}
                                                                                "UNKNOWN"                               {$MemberType = "Unknown"; Break}                                                                           "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                                                Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}                                                                           Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                                        }                                                                   }
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = "    Members"; Value = "Name: $($VDIPoolMember.Name) Type: $MemberType"; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                                                        $ScriptInformation.Add(@{Data = "Name: $($VDIPoolMember.Name)"; Value = "Type: $MemberType"; }) > $Null                                                                           $ScriptInformation.Add(@{Data = ""; Value = "Name: $($VDIPoolMember.Name) Type: $MemberType"; }) > $Null
                                                                    }
                                                                }                                                           }
                                                        }                                                   }
                                                        ElseIf($? -and $Null -eq $VDIPoolMembers)                                                   ElseIf($? -and $Null -eq $VDIPoolMembers)
                                                        {                                                   {
                                                                $ScriptInformation.Add(@{Data = "Members"; Value = "None found"; }) > $Null                                                           $ScriptInformation.Add(@{Data = "    Members"; Value = "None found"; }) > $Null
                                                        }                                                   }
                                                        Else                                                   Else
                                                        {                                                   {
                                                                $ScriptInformation.Add(@{Data = "Members"; Value = "Unable to retrieve"; }) > $Null                                                           $ScriptInformation.Add(@{Data = "    Members"; Value = "Unable to retrieve"; }) > $Null
                                                        }                                                   }
                                                }                                           }
                                        }    
     
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "WildCard"; Value = $VDIPool.WildCard; }) > $Null    
     
 
  <>                                         Line 3 "Pools"
                                        Line 2 "Pool $($VDIPool.Name)"                                           Line 4 "Name`t`t: " $VDIPool.Name
                                            Line 4 "Last modification by`t: " $VDIPool.AdminLastMod
                                            Line 4 "Modified on`t`t: " $VDIPool.TimeLastMod.ToString()
                                            Line 4 "Created by`t`t: " $VDIPool.AdminCreate
                                            Line 4 "Created on`t`t: " $VDIPool.TimeCreate.ToString()
 
  <>                                         ForEach($Item in $VDIPool.Members)
                                            {
                                        $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null                                                    $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null
                                                                                          
                                        If($? -and $Null -ne $VDIPoolMembers)                                                   If($? -and $Null -ne $VDIPoolMembers)
                                        {                                                   {
                                                            $cnt = -1
                                                $VDIPoolMember = $VDIPoolMembers[0]                                                           ForEach($VDIPoolMember in $VDIPoolMembers)
                                                            {
                                                Switch($VDIPoolMember.Type)                                                                   Switch($VDIPoolMember.Type)
                                                {                                                                   {
                                                        "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}                                                                           "ALLGUESTINHOST"                {$MemberType = "All Guest VMs in Host"; Break}
                                                        "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}                                                                           "ALLGUESTSONPROVIDER"   {$MemberType = "All Guest VMs on Provider"; Break}
                                                        "Desktop"                               {$MemberType = "Guest"; Break}    
                                                        "GUEST"                                 {$MemberType = "Guest"; Break}                                                                           "GUEST"                                 {$MemberType = "Guest VM"; Break}
                                                        "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}                                                                           "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                        "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}    
                                                        "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}                                                                           "TEMPLATEGUEST"                 {$MemberType = "Template"; Break}
                                                        "UNKNOWN"                               {$MemberType = "Unknown"; Break}                                                                           "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                        Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}                                                                           Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                }                                                                   }
                                        }    
                                        Else    
                                        {    
                                                $MemberType = ""    
                                        }    
                                                                    $cnt++
                                        Line 3 "Name`t`t`t: " $VDIPool.Name    
                                        Line 3 "Enabled`t`t`t: " $VDIPool.Enabled.ToString()    
                                        Line 3 "Description`t`t: " $VDIPool.Description    
                                        Line 3 "Members type`t`t: " $MemberType    
                                        Line 3 "Last modification by`t: " $VDIPool.AdminLastMod    
                                        Line 3 "Modified on`t`t: " $VDIPool.TimeLastMod.ToString()    
                                        Line 3 "Created by`t`t: " $VDIPool.AdminCreate    
                                        Line 3 "Created on`t`t: " $VDIPool.TimeCreate.ToString()    
                                        Line 0 ""    
                                            
                                        #General    
                                        Line 3 "General"    
                                        Line 4 "Enable pool in site`t: " $VDIPool.Enabled.ToString()    
                                        Line 4 "Name`t`t`t: " $VDIPool.Name    
                                        Line 4 "Description`t`t: " $VDIPool.Description    
                                        Line 0 ""    
                                            
                                        #Members    
                                            
                                        Line 3 "Members"    
                                        If($VDIPool.Members.Count -eq 0)                                                                   If($cnt -eq 0)
                                        {                                                                   {
                                                Line 4 "Members: " "There are no pool members"                                                                           Line 4 "Members`t`t: " "Name: $($VDIPoolMember.Name) Type: $MemberType"
                                        }                                                                   }
                                        Else                                                                   Else
                                        {    
                                                ForEach($Item in $VDIPool.Members)    
                                                {    
                                                        $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null    
                                                            
                                                        If($? -and $Null -ne $VDIPoolMembers)    
                                                        {    
                                                                ForEach($VDIPoolMember in $VDIPoolMembers)    
 
                                                                        Switch($VDIPoolMember.Type) <>  
                                                                        {    
                                                                                "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}    
                                                                                "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}    
                                                                                "Desktop"                               {$MemberType = "Guest"; Break}    
                                                                                "GUEST"                                 {$MemberType = "Guest"; Break}    
                                                                                "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}    
                                                                                "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}    
                                                                                "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}    
                                                                                "UNKNOWN"                               {$MemberType = "Unknown"; Break}    
                                                                                Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}                                                                           Line 6 "Name: $($VDIPoolMember.Name) Type: $MemberType"
                                                                        }                                                                   }
                                                                        Line 4 "Name: $($VDIPoolMember.Name) " "Type: $MemberType"    
                                                                }                                                           }
                                                        }                                                   }
                                                        ElseIf($? -and $Null -eq $VDIPoolMembers)                                                   ElseIf($? -and $Null -eq $VDIPoolMembers)
                                                        {                                                   {
                                                                Line 4 "Members: " "None found"                                                           Line 4 "Members`t`t: " "None found"
                                                        }                                                   }
                                                        Else                                                   Else
                                                        {                                                   {
                                                                Line 4 "Members: " "Unable to retrieve"                                                           Line 4 "Members`t`t: " "Unable to retrieve"
                                                        }    
 
                                        Line 0 "" +-  
                                        Line 4 "WildCard: " $VDIPool.WildCard    
                                        Line 0 ""    
 
                                        WriteHTMLLine 3 0 "Pool $($VDIPool.Name)" +-  
                    
                                        $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null     
                                            
                                        If($? -and $Null -ne $VDIPoolMembers)    
                                        {    
                                                $VDIPoolMember = $VDIPoolMembers[0]    
                                                Switch($VDIPoolMember.Type)    
                                                {    
                                                        "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}    
                                                        "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}    
                                                        "Desktop"                               {$MemberType = "Guest"; Break}    
                                                        "GUEST"                                 {$MemberType = "Guest"; Break}    
                                                        "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}    
                                                        "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}    
                                                        "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}    
                                                        "UNKNOWN"                               {$MemberType = "Unknown"; Break}    
                                                        Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}    
                                                }    
                                        }    
                                        Else    
                                        {    
                                                $MemberType = ""    
                                        }    
     
 
                                        $columnHeaders = @("Name",($Script:htmlsb),$VDIPool.Name,$htmlwhite) <>                                         $columnHeaders = @("Pools",($Script:htmlsb),"",$htmlwhite)
                                        $rowdata += @(,("Enabled",($Script:htmlsb),$VDIPool.Enabled.ToString(),$htmlwhite))                                           $rowdata += @(,("  Name",($Script:htmlsb),$VDIPool.Name,$htmlwhite))
                                        $rowdata += @(,("Description",($Script:htmlsb),$VDIPool.Description,$htmlwhite))    
                                        $rowdata += @(,("Members type: ",($Script:htmlsb),$MemberType,$htmlwhite))    
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $VDIPool.AdminLastMod,$htmlwhite))                                           $rowdata += @(,("  Last modification by",($Script:htmlsb), $VDIPool.AdminLastMod,$htmlwhite))
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $VDIPool.TimeLastMod.ToString(),$htmlwhite))                                           $rowdata += @(,("  Modified on",($Script:htmlsb), $VDIPool.TimeLastMod.ToString(),$htmlwhite))
                                        $rowdata += @(,("Created by",($Script:htmlsb), $VDIPool.AdminCreate,$htmlwhite))                                           $rowdata += @(,("  Created by",($Script:htmlsb), $VDIPool.AdminCreate,$htmlwhite))
                                        $rowdata += @(,("Created on",($Script:htmlsb), $VDIPool.TimeCreate.ToString(),$htmlwhite))                                           $rowdata += @(,("  Created on",($Script:htmlsb), $VDIPool.TimeCreate.ToString(),$htmlwhite))
 
                                                                        "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break} <>                                                                         "ALLGUESTINHOST"                {$MemberType = "All Guest VMs in Host"; Break}
                                                                        "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}                                                                           "ALLGUESTSONPROVIDER"   {$MemberType = "All Guest VMs on Provider"; Break}
                                                                        "Desktop"                               {$MemberType = "Guest"; Break}    
                                                                        "GUEST"                                 {$MemberType = "Guest"; Break}                                                                           "GUEST"                                 {$MemberType = "Guest VM"; Break}
 
                                                                        "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break} <>  
                                                                        "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}                                                                           "TEMPLATEGUEST"                 {$MemberType = "Template"; Break}
 
  +-  
                                        #General    
                                    
                                        $rowdata = @()    
                                        $columnHeaders = @("Enable pool in site",($Script:htmlsb),$VDIPool.Enabled.ToString(),$htmlwhite)    
                                        $rowdata += @(,("Name",($Script:htmlsb),$VDIPool.Name,$htmlwhite))    
                                        $rowdata += @(,("Description",($Script:htmlsb),$VDIPool.Description,$htmlwhite))    
                                            
                                        $msg = "General"    
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
     
                                        #Members    
                            
                                        $rowdata = @()    
                                        If($VDIPool.Members.Count -eq 0)    
                                        {    
                                                $columnHeaders = @("Members",($Script:htmlsb),"There are no pool members",$htmlwhite)    
                                        }    
                                        Else    
                                        {    
                                                ForEach($Item in $VDIPool.Members)    
                                                {    
                                                        $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null    
                                                            
                                                        If($? -and $Null -ne $VDIPoolMembers)    
                                                        {    
                                                                $cnt = -1    
                                                                ForEach($VDIPoolMember in $VDIPoolMembers)    
                                                                {    
                                                                        Switch($VDIPoolMember.Type)    
                                                                        {    
                                                                                "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}    
                                                                                "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}    
                                                                                "Desktop"                               {$MemberType = "Guest"; Break}    
                                                                                "GUEST"                                 {$MemberType = "Guest"; Break}    
                                                                                "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}    
                                                                                "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}    
                                                                                "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}    
                                                                                "UNKNOWN"                               {$MemberType = "Unknown"; Break}    
                                                                                Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}    
                                                                        }    
                                                                        $cnt++    
                                                                        If($cnt -eq 0)    
                                                                        {    
                                                                                $columnHeaders = @("Name: $($VDIPoolMember.Name)",($Script:htmlsb),"Type: $MemberType",$htmlwhite)    
                                                                        }    
                                                                        Else    
                                                                        {    
                                                                                $rowdata += @(,("Name: $($VDIPoolMember.Name)",($Script:htmlsb),"Type: $MemberType",$htmlwhite))    
                                                                        }    
                                                                }    
                                                        }    
                                                        ElseIf($? -and $Null -eq $VDIPoolMembers)    
                                                        {    
                                                                $rowdata += @(,("Members",($Script:htmlsb),"None found",$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("Members",($Script:htmlsb),"Unable to retrieve",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
                                            
                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))    
                                        $rowdata += @(,("WildCard",($Script:htmlsb),$VDIPool.WildCard,$htmlwhite))    
     
                                        $msg = "Members"    
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
 
                Write-Verbose "$(Get-Date -Format G): `tOutput VDI Templates" +-  
 
                $VDITemplates = Get-RASVDITemplate -SiteId $Site.Id -EA 0 4>$Null | Where-Object {$_.TemplateType -eq "VDIDesktop"} <>  
                If(!$?)    
                {    
                        Write-Warning "    
                        `n    
                        Unable to retrieve VDI Templates for Site $($Site.Name)`    
                        "    
                        If($MSWord -or $PDF)                   If($MSWord -or $PDF)
                        {                   {
                                WriteWordLine 0 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"                           WriteWordLine 3 0 "Templates"
                        }                   }
                        If($Text)                   If($Text)
                        {                   {
                                Line 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"                           Line 2 "Templates"
                        }                   }
                        If($HTML)                   If($HTML)
                        {                   {
                                WriteHTMLLine 0 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"                           WriteHTMLLine 3 0 "Templates"
                        }                   }
                }                  
                    $VDITemplates = Get-RASVDITemplate -SiteId $Site.Id -EA 0 4>$Null
                ElseIf($? -and $Null -eq $VDITemplates)                   If($? -and $Null -ne $VDITemplates)
 
                        Write-Host " +-  
        No VDI Templates retrieved for Site $($Site.Name).`    
                        " -ForegroundColor White    
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 0 0 "No VDI Templates retrieved for Site $($Site.Name)"    
                        }    
                        If($Text)    
                        {    
                                Line 0 "No VDI Templates retrieved for Site $($Site.Name)"    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 0 0 "No VDI Templates retrieved for Site $($Site.Name)"    
                        }    
                }    
                Else    
                {    
 
                                If($MSWord -or $PDF) <>  
                                {    
                                        WriteWordLine 3 0 "Template $($VDITemplate.Name)"    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Template $($VDITemplate.Name)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 3 0 "Template $($VDITemplate.Name)"    
                                }    
                                    
                                $TemplateProvider = Get-RASProvider -Id $RDSTemplate.ProviderId -EA 0 4>$Null                                   $VDIHost = Get-RASProvider -Id $VDITemplate.ProviderId -EA 0 4>$Null
 
                                If($? -and $Null -ne $TemplateProvider) <>                                 If($? -and $null -ne $VDIHost)
 
                                        $TemplateProviderName = $TemplateProvider.Server <>                                         $Provider     = $VDIHost.Server
                                        $TemplateProviderType = GetVDIType $TemplateProvider.Type                                           $ProviderType = GetVDIType $VDIHost.Type
                                }                                           
                                Else                                           #$ProviderStatus = (Get-RASProviderStatus -Id $VDITemplate.ProviderId -EA 0 4>$Null) 
                                {    
                                        $TemplateProviderName = ""    
                                        $TemplateProviderType = ""    
 
                                 <>  
                                $TemplateVM = Get-RASVM -Id $VDITemplate.VMId -ProviderId $VDITemplate.ProviderId -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $TemplateVM)                                   ElseIf($? -$Null -eq $VDIHost)
 
                                        <# <>                                         $Provider       = "No Provider found"
                                                Values          Description    
                                                Unknown         The VM is in the 'Unknown' state    
                                                On                  The VM is powered on.                                           $ProviderTyp  = "Unknown"
                                                Off                 The VM is powered off                                           #$ProviderStatus = "Unknown"
                                                Paused          The VM is already, or in the process of being, suspended    
                                                CloningFailed   Failed to clone the VM.    
                                                CloningCanceled VM cloning was cancelled    
                                        #>    
                                        Switch($TemplateVM.State)    
                                        {    
                                                "Unknown"                       {$TemplatePowerState = "Unknown"; Break}    
                                                "On"                            {$TemplatePowerState = "Powered on"; Break}    
                                                "Off"                           {$TemplatePowerState = "Powered off"; Break}    
                                                "Paused"                        {$TemplatePowerState = "Paused"; Break}    
                                                "CloningFailed"         {$TemplatePowerState = "Cloning failed"; Break}    
                                                "CloningCanceled"       {$TemplatePowerState = "Cloning canceled"; Break}    
                                                Default                         {$TemplatePowerState = "Unable to determine template VM power state: $($TemplateVM.State)"; Break}    
                                        }    
 
  <>                                         $Provider       = "Unable to retrieve Provider with an ID of $($VDITemplate.ProviderId)"
                                        $TemplatePowerState = "Unknown"                                           $ProviderType   = "Unknown"
                                            #$ProviderStatus = "Unknown"
 
                                        #$ScriptInformation.Add(@{Data = "Status"; Value = "Can't find"; }) > $Null <>                                         #$ScriptInformation.Add(@{Data = "Status"; Value = $ProviderStatus; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Power state"; Value = $TemplatePowerState; }) > $Null                                           $ScriptInformation.Add(@{Data = "Type"; Value = $VDITemplate.TemplateType.ToString(); }) > $Null
                                        #$ScriptInformation.Add(@{Data = "Agent status"; Value = "Can't find"; }) > $Null    
                                        #$ScriptInformation.Add(@{Data = "Distribution"; Value = "Can't find"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Provider"; Value = $TemplateProviderName; }) > $Null                                           $ScriptInformation.Add(@{Data = "Provider"; Value = $Provider; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Provider type"; Value = $TemplateProviderType; }) > $Null                                           $ScriptInformation.Add(@{Data = "Provider Type"; Value = $ProviderType; }) > $Null
 
                                        Line 3 "Name: " $VDITemplate.Name <>                                         Line 3 "Name`t`t`t: " $VDITemplate.Name
                                        #Line 3 "Status`t`t`t: " "Can't find"                                           #Line 3 "Status`t`t`t: " $ProviderStatus
                                        Line 3 "Power state`t`t: " $TemplatePowerState                                           Line 3 "Type`t`t`t: " $VDITemplate.TemplateType.ToString()
                                        #Line 3 "Agent status`t`t: " "Can't find"    
                                        #Line 3 "Distribution`t`t: " "Can't find"    
                                        Line 3 "Provider`t`t: " $TemplateProviderName                                           Line 3 "Provider`t`t: " $Provider
                                        Line 3 "Provider type`t`t: " $TemplateProviderType                                           Line 3 "Provider Type`t`t: " $ProviderType
 
                                        #$rowdata += @(,("Status",($Script:htmlsb),"Can't find",$htmlwhite)) <>                                         #$rowdata += @(,("Status",($Script:htmlsb),$ProviderStatus,$htmlwhite))
                                        $rowdata += @(,("Power state",($Script:htmlsb),$TemplatePowerState,$htmlwhite))                                           $rowdata += @(,("Type",($Script:htmlsb),$VDITemplate.TemplateType.ToString(),$htmlwhite))
                                        #$rowdata += @(,("Agent status",($Script:htmlsb),"Can't find",$htmlwhite))    
                                        #$rowdata += @(,("Distribution",($Script:htmlsb),"Can't find",$htmlwhite))    
                                        $rowdata += @(,("Provider",($Script:htmlsb),$TemplateProviderName,$htmlwhite))                                           $rowdata += @(,("Provider",($Script:htmlsb),$Provider,$htmlwhite))
                                        $rowdata += @(,("Provider type",($Script:htmlsb),$TemplateProviderType,$htmlwhite))                                           $rowdata += @(,("Provider type",($Script:htmlsb),$ProviderType,$htmlwhite))
 
                                Switch ($VDITemplate.UnusedVMDurationMins) <>                                 Switch ($VDITemplate.UnusedGuestDurationMins)
 
                                        0               {$DeleteVMTime = "Never"; Break} <>                                         0               {$DeleteVMsTime = "Never"; Break}
                                        5               {$DeleteVMTime = "5 minutes"; Break}    
                                        30              {$DeleteVMTime = "30 minutes"; Break}    
                                        60              {$DeleteVMTime = "1 hour"; Break}    
                                        1440    {$DeleteVMTime = "1 day"; Break}                                           1440    {$DeleteVMsTime = "1 day"; Break}
                                        10080   {$DeleteVMTime = "1 week"; Break}                                           10080   {$DeleteVMsTime = "1 week"; Break}
                                        43200   {$DeleteVMTime = "30 days"; Break}                                           43200   {$DeleteVMsTime = "30 days"; Break}
                                        Default {$DeleteVMTime = "Unable to determine Delete unused VMs after: $($VDITemplate.UnusedVMDurationMins)"; Break}                                           Default {$DeleteVMsTime = "Unable to determine Delete unused guest VMs after: $($VDITemplate.UnusedGuestDurationMins)"; Break}
 
                                        $ScriptInformation.Add(@{Data = "Maximum guest VMs"; Value = $VDITemplate.MaxVMs.ToString(); }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Maximum guest VMs"; Value = $VDITemplate.MaxGuests.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Keep available buffer"; Value = $VDITemplate.PreCreatedVMs.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Keep available buffer"; Value = $VDITemplate.PreCreatedGuests.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Guest VM name"; Value = $VDITemplate.VMNameFormat; }) > $Null                                           $ScriptInformation.Add(@{Data = "Guest VM name"; Value = $VDITemplate.GuestNameFormat; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Guest VM state after the preparation"; Value = "Can't find"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Delete unused guest VMs after"; Value = $DeleteVMTime; }) > $Null                                           $ScriptInformation.Add(@{Data = "Delete unused guest VMs after"; Value = $DeleteVMsTime; }) > $Null
 
                                        Line 4 "Maximum guest VMs`t`t: " $VDITemplate.MaxVMs.ToString() <>                                         Line 4 "Maximum guest VMs`t`t: " $VDITemplate.MaxGuests.ToString()
                                        Line 4 "Keep available buffer`t`t: " $VDITemplate.PreCreatedVMs.ToString()                                           Line 4 "Keep available buffer`t`t: " $VDITemplate.PreCreatedGuests.ToString()
                                        Line 4 "Guest VM state after the preparation`t: " "Can't find"    
                                        Line 4 "Guest VM name`t`t`t: " $VDITemplate.VMNameFormat                                           Line 4 "Guest VM name`t`t`t: " $VDITemplate.GuestNameFormat
                                        Line 4 "Delete unused guest VMs after`t: " $DeleteVMTime                                           Line 4 "Delete unused guest VMs after`t: " $DeleteVMsTime
 
                                        $rowdata += @(,("Maximum guest VMs",($Script:htmlsb),$VDITemplate.MaxVMs.ToString(),$htmlwhite)) <>                                         $rowdata += @(,("Maximum guest VMs",($Script:htmlsb),$VDITemplate.MaxGuests.ToString(),$htmlwhite))
                                        $rowdata += @(,("Keep available buffer",($Script:htmlsb),$VDITemplate.PreCreatedVMs.ToString(),$htmlwhite))                                           $rowdata += @(,("Keep available buffer",($Script:htmlsb),$VDITemplate.PreCreatedGuests.ToString(),$htmlwhite))
                                        $rowdata += @(,("Guest VM name",($Script:htmlsb),$VDITemplate.VMNameFormat,$htmlwhite))                                           $rowdata += @(,("Guest VM name",($Script:htmlsb),$VDITemplate.GuestNameFormat,$htmlwhite))
                                        $rowdata += @(,("Guest VM state after the preparation",($Script:htmlsb),"Can't find",$htmlwhite))    
                                        $rowdata += @(,("Delete unused guest VMs after",($Script:htmlsb),$DeleteVMTime,$htmlwhite))                                           $rowdata += @(,("Delete unused guest VMs after",($Script:htmlsb),$DeleteVMsTime,$htmlwhite))
 
                                        $ScriptInformation.Add(@{Data = "Enable hardware acceleration graphics licensing support"; Value = $VDITemplate.HWGPU.ToString(); }) > $Null +-  
                                        #$ScriptInformation.Add(@{Data = "Use a separate network interface for LAN access"; Value = "Can't find"; }) > $Null    
                                        #$ScriptInformation.Add(@{Data = "Specify management network details"; Value = ""; }) > $Null    
                                        #$ScriptInformation.Add(@{Data = "     Address"; Value = ""; }) > $Null    
                                        #$ScriptInformation.Add(@{Data = "     Subnet mask"; Value = ""; }) > $Null    
 
                                        Line 4 "Enable hardware acceleration " +-  
                                        Line 4 "graphics licensing support`t: " $VDITemplate.HWGPU.ToString()    
                                        #Line 4 "Use a separate network interface for LAN access: " "Can't find"    
                                        #Line 4 "Specify management network details:"    
                                        #Line 5 "Address`t`t`t: " $DeleteVMTime    
                                        #Line 6 "Subnet mask`t`t: " $CloneMethod    
 
                                        $rowdata += @(,("Enable hardware acceleration graphics licensing support",($Script:htmlsb),$VDITemplate.HWGPU.ToString(),$htmlwhite)) +-  
                                        #$rowdata += @(,("Use a separate network interface for LAN access",($Script:htmlsb),"Can't find",$htmlwhite))    
                                        #$rowdata += @(,("Specify management network details",($Script:htmlsb),"",$htmlwhite))    
                                        #$rowdata += @(,("     Address",($Script:htmlsb),"",$htmlwhite))    
                                        #$rowdata += @(,("     Subnet mask",($Script:htmlsb),"",$htmlwhite))    
 
                                        $ScriptInformation.Add(@{Data = "Active Directory domain"; Value = ""; }) > $Null <>  
                                        $ScriptInformation.Add(@{Data = "     Domain"; Value = $VDITemplate.Domain; }) > $Null                                           $ScriptInformation.Add(@{Data = "Join domain"; Value = $VDITemplate.Domain; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Administrator"; Value = $VDITemplate.Administrator; }) > $Null                                           $ScriptInformation.Add(@{Data = "Administrator"; Value = $VDITemplate.Administrator; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Target OU"; Value = $VDITemplate.DomainOrgUnit; }) > $Null                                           $ScriptInformation.Add(@{Data = "Target OU"; Value = $VDITemplate.DomainOrgUnit; }) > $Null
 
                                        Line 4 "Image preparation tool`t: " $VDITemplate.ImagePrepTool.ToString() <>                                         Line 4 "Image preparation tool`t`t: " $VDITemplate.ImagePrepTool.ToString()
                                        Line 4 "Computer name`t`t: " $VDITemplate.ComputerName                                           Line 4 "Computer name`t`t`t: " $VDITemplate.ComputerName
                                        Line 4 "Owner name`t`t: " $VDITemplate.OwnerName                                           Line 4 "Owner name`t`t`t: " $VDITemplate.OwnerName
                                        Line 4 "Organization`t`t: " $VDITemplate.Organization                                           Line 4 "Organization`t`t`t: " $VDITemplate.Organization
                                        Line 4 "Active Directory domain"    
                                        Line 5 "Domain`t`t: " $VDITemplate.Domain                                           Line 4 "Join domain`t`t`t: " $VDITemplate.Domain
                                        Line 5 "Administrator`t: " $VDITemplate.Administrator                                           Line 4 "Administrator`t`t`t: " $VDITemplate.Administrator
                                        Line 5 "Target OU`t: " $VDITemplate.DomainOrgUnit                                           Line 4 "Target OU`t`t`t: " $VDITemplate.DomainOrgUnit
 
                                        $rowdata += @(,("Active Directory domain",($Script:htmlsb),"",$htmlwhite)) <>  
                                        $rowdata += @(,("     Domain",($Script:htmlsb),$VDITemplate.Domain,$htmlwhite))                                           $rowdata += @(,("Join domain",($Script:htmlsb),$VDITemplate.Domain,$htmlwhite))
                                        $rowdata += @(,("     Administrator",($Script:htmlsb),$VDITemplate.Administrator,$htmlwhite))                                           $rowdata += @(,("Administrator",($Script:htmlsb),$VDITemplate.Administrator,$htmlwhite))
                                        $rowdata += @(,("     Target OU",($Script:htmlsb),$VDITemplate.DomainOrgUnit,$htmlwhite))                                           $rowdata += @(,("Target OU",($Script:htmlsb),$VDITemplate.DomainOrgUnit,$htmlwhite))
 
  -+                                 #There is no way to retrieve the settings if "Inherit default settings" is selected.
                                    #There is also no way to retrieve the Site Defaults, which are more than User profile settings
                                    #I will leave this code in but commented out
 
                                If($MSWord -or $PDF) <>                                 <#If($MSWord -or $PDF)
 
                                If($VDITemplate.InheritDefaultUserProfileSettings) <>                                 If($VDITemplate.InheritDefUserProfileSettings)
 
                                        $TemplateDefaults = Get-RASVDIDefaultSettings -SiteId $Site.Id -EA 0 4>$Null <>                                         $TemplateDefaults = Get-RASRDSDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
 
                                                #$FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate <>                                                 $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
 
                                                #$FSLogixDeploymentSettingsReplicate             = $False <>                                                 $FSLogixDeploymentSettingsReplicate             = $False
 
                                                Default                                         {$TemplateTechnology = "Unable to determine Technology State: $($VDITemplate.Technology)"; Break} <>                                                 Default                                         {$TemplateTechnology = "Unable to determine Technology State: $($TemplateDefaults.Technology)"; Break}
 
                                        #$FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate <>                                         $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
 
                                        $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefaultUserProfileSettings.ToString(); }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefUserProfileSettings.ToString(); }) > $Null
 
                                                #$ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null <>                                                 $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null
 
                                        Line 3 "Inherit default settings`t`t`t`t: " $VDITemplate.InheritDefaultUserProfileSettings.ToString() <>                                         Line 3 "Inherit default settings`t`t`t`t: " $VDITemplate.InheritDefUserProfileSettings.ToString()
 
                                                #Line 3 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString() <>                                                 Line 3 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString()
 
                                                Line 5 "Access network as computer object                    $($FSLogixAS_AccessNetworkAsComputerObject)" <>                                                 Line 6 "Access network as computer object                    $($FSLogixAS_AccessNetworkAsComputerObject)"
                                                Line 5 "Custom SDDL for profile directory                    $($FSLogixAS_ProfileDirSDDL)"                                                   Line 6 "Custom SDDL for profile directory                    $($FSLogixAS_ProfileDirSDDL)"
                                                Line 5 "Delay between locked VHD(X) retries                  $($FSLogixAS_LockedRetryInterval)"                                                   Line 6 "Delay between locked VHD(X) retries                  $($FSLogixAS_LockedRetryInterval)"
                                                Line 5 "Delete local profile when loading from VHD           $($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)"                                                   Line 6 "Delete local profile when loading from VHD           $($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)"
                                                Line 5 "Diff disk parent folder path                         $($FSLogixAS_DiffDiskParentFolderPath)"                                                   Line 6 "Diff disk parent folder path                         $($FSLogixAS_DiffDiskParentFolderPath)"
                                                Line 5 "Do not create a folder for new profiles              $($FSLogixAS_NoProfileContainingFolder)"                                                   Line 6 "Do not create a folder for new profiles              $($FSLogixAS_NoProfileContainingFolder)"
                                                Line 5 "Enable Cached mode for Outlook                       $($FSLogixAS_OutlookCachedMode)"                                                   Line 6 "Enable Cached mode for Outlook                       $($FSLogixAS_OutlookCachedMode)"
                                                Line 5 "Keep local profiles                                  $($FSLogixAS_KeepLocalDir)"                                                   Line 6 "Keep local profiles                                  $($FSLogixAS_KeepLocalDir)"
                                                Line 5 "Naming pattern for new VHD(X) files                  $($FSLogixAS_VHDNamePattern)"                                                   Line 6 "Naming pattern for new VHD(X) files                  $($FSLogixAS_VHDNamePattern)"
                                                Line 5 "Number of locked VHD(X) retries                      $($FSLogixAS_LockedRetryCount)"                                                   Line 6 "Number of locked VHD(X) retries                      $($FSLogixAS_LockedRetryCount)"
                                                Line 5 "Prevent logons with failures                         $($FSLogixAS_PreventLoginWithFailure)"                                                   Line 6 "Prevent logons with failures                         $($FSLogixAS_PreventLoginWithFailure)"
                                                Line 5 "Prevent logons with temp profiles                    $($FSLogixAS_PreventLoginWithTempProfile)"                                                   Line 6 "Prevent logons with temp profiles                    $($FSLogixAS_PreventLoginWithTempProfile)"
                                                Line 5 "Profile folder naming pattern                        $($FSLogixAS_SIDDirNameMatch)"                                                   Line 6 "Profile folder naming pattern                        $($FSLogixAS_SIDDirNameMatch)"
                                                Line 5 "Profile type                                         $($FSLogixAS_ProfileType)"                                                   Line 6 "Profile type                                         $($FSLogixAS_ProfileType)"
                                                Line 5 "Profile VHD(X) file matching pattern                 $($FSLogixAS_VHDNameMatch)"                                                   Line 6 "Profile VHD(X) file matching pattern                 $($FSLogixAS_VHDNameMatch)"
                                                Line 5 "Re-attach interval                                   $($FSLogixAS_ReAttachIntervalSeconds)"                                                   Line 6 "Re-attach interval                                   $($FSLogixAS_ReAttachIntervalSeconds)"
                                                Line 5 "Re-attach retry limit                                $($FSLogixAS_ReAttachRetryCount)"                                                   Line 6 "Re-attach retry limit                                $($FSLogixAS_ReAttachRetryCount)"
                                                Line 5 "Remove duplicate OST files on logoff                 $($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)"                                                   Line 6 "Remove duplicate OST files on logoff                 $($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)"
                                                Line 5 "SDDL used when attaching the VHD                     $($FSLogixAS_AttachVHDSDDL)"                                                   Line 6 "SDDL used when attaching the VHD                     $($FSLogixAS_AttachVHDSDDL)"
                                                Line 5 "Search roaming feature mode                          $($FSLogixAS_RoamSearch)"                                                   Line 6 "Search roaming feature mode                          $($FSLogixAS_RoamSearch)"
                                                Line 5 "Swap SID and username in profile directory names     $($FSLogixAS_FlipFlopProfileDirectoryName)"                                                   Line 6 "Swap SID and username in profile directory names     $($FSLogixAS_FlipFlopProfileDirectoryName)"
                                                Line 5 "Temporary folders redirection mode                   $($FSLogixAS_SetTempToLocalPath)"                                                   Line 6 "Temporary folders redirection mode                   $($FSLogixAS_SetTempToLocalPath)"
                                                Line 5 "Use SDDL on creation of SID containing folder        $($FSLogixAS_SIDDirSDDL)"                                                   Line 6 "Use SDDL on creation of SID containing folder        $($FSLogixAS_SIDDirSDDL)"
                                                Line 5 "User-to-Profile matching pattern                     $($FSLogixAS_SIDDirNamePattern)"                                                   Line 6 "User-to-Profile matching pattern                     $($FSLogixAS_SIDDirNamePattern)"
                                                Line 5 "VHDX sector size                                     $($FSLogixAS_VHDXSectorSize)"                                                   Line 6 "VHDX sector size                                     $($FSLogixAS_VHDXSectorSize)"
                                                Line 5 "Volume wait time                                     $($FSLogixAS_VolumeWaitTimeMS)"                                                   Line 6 "Volume wait time                                     $($FSLogixAS_VolumeWaitTimeMS)"
 
                                        $columnHeaders = @("Inherit default settings",($Script:htmlsb),$VDITemplate.InheritDefaultUserProfileSettings.ToString(),$htmlwhite) <>                                         $columnHeaders = @("Inherit default settings",($Script:htmlsb),$VDITemplate.InheritDefUserProfileSettings.ToString(),$htmlwhite)
 
                                                #$rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite)) <>                                                 $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite))
 
                                #Optimization +-  
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 4 0 "Optimization"    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Optimization"    
                                }    
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
     
                                If($VDITemplate.InheritDefaultOptimizationSettings)    
                                {    
                                        #do we inherit site defaults?    
                                        #http://woshub.com/hot-to-convert-sid-to-username-and-vice-versa/    
                                        #for translating the User SID to the AD user name    
                                        #yes we do, get the default settings for the Site    
                                        #use the Site default settings    
                                        $VDIDefaults = Get-RASVDIDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                            
                                        If($? -and $Null -ne $VDIDefaults)    
                                        {    
                                                $OPTEnableOptimization            = $VDIDefaults.Optimization.EnableOptimization.ToString()    
                                                $OPTOptimizationType              = $VDIDefaults.Optimization.OptimizationType.ToString()    
                                                $OPTWindowsDefenderATPEnabled     = $VDIDefaults.Optimization.WindowsDefenderATPEnabled.ToString()        
                                                $OPTWindowsComponentsEnabled      = $VDIDefaults.Optimization.WindowsComponentsEnabled.ToString()    
                                                $OPTWindowsServicesEnabled        = $VDIDefaults.Optimization.WindowsServicesEnabled.ToString()    
                                                $OPTWinodwsScheduledTasksEnabled  = $VDIDefaults.Optimization.WindowsScheduledTasksEnabled.ToString()    
                                                $OPTWindowsAdvancedOptionsEnabled = $VDIDefaults.Optimization.WindowsAdvancedOptionsEnabled.ToString()    
                                                $OPTNetworkPerformanceEnabled     = $VDIDefaults.Optimization.NetworkPerformanceEnabled.ToString()    
                                                $OPTRegistryEnabled               = $VDIDefaults.Optimization.RegistryEnabled.ToString()    
                                                $OPTVisualEffectsEnabled          = $VDIDefaults.Optimization.VisualEffectsEnabled.ToString()       
                                                $OPTDiskCleanupEnabled            = $VDIDefaults.Optimization.DiskCleanupEnabled.ToString()    
                                                $OPTCustomScriptEnabled           = $VDIDefaults.Optimization.CustomScriptEnabled.ToString()    
                                        }    
                                        Else    
                                        {    
                                                #unable to retrieve default, use built-in default values    
                                                $OPTEnableOptimization            = "False"    
                                                $OPTOptimizationType              = ""    
                                                $OPTWindowsDefenderATPEnabled     = "False"    
                                                $OPTWindowsComponentsEnabled      = "False"    
                                                $OPTWindowsServicesEnabled        = "False"    
                                                $OPTWinodwsScheduledTasksEnabled  = "False"    
                                                $OPTWindowsAdvancedOptionsEnabled = "False"    
                                                $OPTNetworkPerformanceEnabled     = "False"    
                                                $OPTRegistryEnabled               = "False"    
                                                $OPTVisualEffectsEnabled          = "False"    
                                                $OPTDiskCleanupEnabled            = "False"    
                                                $OPTCustomScriptEnabled           = "False"    
                                        }    
                                }    
                                Else    
                                {    
                                        #we don't inherit    
                                        #get the settings for the template    
                                            
                                        $OPTEnableOptimization            = $VDITemplate.Optimization.EnableOptimization.ToString()    
                                        $OPTOptimizationType              = $VDITemplate.Optimization.OptimizationType.ToString()    
                                        $OPTWindowsDefenderATPEnabled     = $VDITemplate.Optimization.WindowsDefenderATPEnabled.ToString()        
                                        $OPTWindowsComponentsEnabled      = $VDITemplate.Optimization.WindowsComponentsEnabled.ToString()    
                                        $OPTWindowsServicesEnabled        = $VDITemplate.Optimization.WindowsServicesEnabled.ToString()    
                                        $OPTWinodwsScheduledTasksEnabled  = $VDITemplate.Optimization.WindowsScheduledTasksEnabled.ToString()    
                                        $OPTWindowsAdvancedOptionsEnabled = $VDITemplate.Optimization.WindowsAdvancedOptionsEnabled.ToString()    
                                        $OPTNetworkPerformanceEnabled     = $VDITemplate.Optimization.NetworkPerformanceEnabled.ToString()    
                                        $OPTRegistryEnabled               = $VDITemplate.Optimization.RegistryEnabled.ToString()    
                                        $OPTVisualEffectsEnabled          = $VDITemplate.Optimization.VisualEffectsEnabled.ToString()       
                                        $OPTDiskCleanupEnabled            = $VDITemplate.Optimization.DiskCleanupEnabled.ToString()    
                                        $OPTCustomScriptEnabled           = $VDITemplate.Optimization.CustomScriptEnabled.ToString()    
                                }    
     
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefaultUserProfileSettings.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Enable optimization"; Value = $OPTEnableOptimization; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Optimization type"; Value = $OPTOptimizationType; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 250;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
     
                                        WriteWordLine 5 0 "Windows Defender ATP:" $OPTWindowsDefenderATPEnabled    
                                        If($OPTWindowsDefenderATPEnabled -eq "True")    
                                        {    
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $ScriptInformation.Add(@{Data = "Windows Defender ATP Optimizations"; Value = ""; }) > $Null    
     
                                                If($VDITemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "     Turn off Windows Defender ATP (I use my own ATP solution)"; Value = ""; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "     Turn on Windows Defender ATP and set process and folder exclusions"; Value = ""; }) > $Null    
                                                        $ScriptInformation.Add(@{Data = "     Disable real-time protection"; Value = $VDITemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(); }) > $Null    
                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                            
                                                        $cnt = -1    
                                                        ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeFolders)    
                                                        {    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = "     Exclude files and folders"; Value = $item; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null    
                                                                }    
                                                        }    
     
                                                        $cnt = -1    
                                                        ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)    
                                                        {    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = "     Exclude processes"; Value = $item; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null    
                                                                }    
                                                        }    
                                                            
                                                        $cnt = -1    
                                                        ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeExtension)    
                                                        {    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = "     Exclude extensions"; Value = $item; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null    
                                                                }    
                                                        }    
                                                }    
     
                                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                                -Columns Data,Value `    
                                                -List `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 250;    
                                                $Table.Columns.Item(2).Width = 250;    
     
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
     
                                        WriteWordLine 5 0 "Windows Components:" $OPTWindowsComponentsEnabled    
                                        If($OPTWindowsComponentsEnabled -eq "True")    
                                        {    
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $ScriptInformation.Add(@{Data = "Windows Components Optimizations"; Value = ""; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Disable (remove) components:"; Value = ""; }) > $Null    
     
                                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                                -Columns Data,Value `    
                                                -List `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 200;    
                                                $Table.Columns.Item(2).Width = 15;    
     
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
     
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $OptimizationTable = @()    
                            
                                                ForEach($item in $VDITemplate.Optimization.WindowsComponents.WindowsComponentsList)    
                                                {    
                                                                If($Null -eq $item.DisplayName)    
                                                                {    
                                                                        $DisplayName = ""    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $DisplayName = $item.DisplayName    
                                                                }    
                                                                If($Null -eq $item.ComponentName)    
                                                                {    
                                                                        $ComponentName = ""    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ComponentName = $item.ComponentName    
                                                                }    
                                                        $OptimizationTable += @{    
                                                                DisplayName = $DisplayName    
                                                                ComponentName = $ComponentName    
                                                        }    
                                                }    
     
                                                If($OptimizationTable.Count -gt 0)    
                                                {    
                                                        $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                        -Columns DisplayName, ComponentName `    
                                                        -Headers "Display name", "Component" `    
                                                        -Format $wdTableGrid `    
                                                        -AutoFit $wdAutoFitFixed;    
     
                                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                        $Table.Columns.Item(1).Width = 200;    
                                                        $Table.Columns.Item(2).Width = 200;    
                                                            
                                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                        FindWordDocumentEnd    
                                                        $Table = $Null    
                                                        WriteWordLine 0 0 ""    
                                                }    
                                        }    
     
                                        WriteWordLine 5 0 "Windows Services: " $OPTWindowsServicesEnabled           
                                        If($OPTWindowsServicesEnabled -eq "True")    
                                        {    
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $ScriptInformation.Add(@{Data = "Windows Services Optimizations"; Value = ""; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Disable services:"; Value = ""; }) > $Null    
     
                                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                                -Columns Data,Value `    
                                                -List `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 200;    
                                                $Table.Columns.Item(2).Width = 15;    
     
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
     
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $OptimizationTable = @()    
                            
                                                ForEach($item in $VDITemplate.Optimization.WindowsServices.WindowsServicesList)    
                                                {    
                                                                If($Null -eq $item.DisplayName)    
                                                                {    
                                                                        $DisplayName = ""    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $DisplayName = $item.DisplayName    
                                                                }    
                                                                If($Null -eq $item.ServiceName)    
                                                                {    
                                                                        $Service = ""    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $Service = $item.ServiceName    
                                                                }    
                                                                If($Null -eq $item.Aliases)    
                                                                {    
                                                                        $Aliases = ""    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $Aliases = $item.Aliases    
                                                                }    
                                                        $OptimizationTable += @{    
                                                                DisplayName = $DisplayName    
                                                                Service     = $Service    
                                                                Aliases     = $Aliases    
                                                        }    
                                                }    
     
                                                If($OptimizationTable.Count -gt 0)    
                                                {    
                                                        $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                        -Columns DisplayName, Service, Aliases `    
                                                        -Headers "Display name", "Service", "Aliases" `    
                                                        -Format $wdTableGrid `    
                                                        -AutoFit $wdAutoFitFixed;    
     
                                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                        $Table.Columns.Item(1).Width = 200;    
                                                        $Table.Columns.Item(2).Width = 100;    
                                                        $Table.Columns.Item(3).Width = 50;    
                                                            
                                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                        FindWordDocumentEnd    
                                                        $Table = $Null    
                                                        WriteWordLine 0 0 ""    
                                                }    
                                        }    
                                            
                                        WriteWordLine 5 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled     
                                        If($OPTWinodwsScheduledTasksEnabled -eq "True")    
                                        {    
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $ScriptInformation.Add(@{Data = "Windows Scheduled Tasks Optimizations"; Value = ""; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Disable tasks:"; Value = ""; }) > $Null    
     
                                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                                -Columns Data,Value `    
                                                -List `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 200;    
                                                $Table.Columns.Item(2).Width = 15;    
     
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
     
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $OptimizationTable = @()    
                            
                                                ForEach($item in $VDITemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)    
                                                {    
                                                                If($Null -eq $item.Task)    
                                                                {    
                                                                        $Task = ""    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $Task = $item.Task    
                                                                }    
                                                                If($Null -eq $item.Type)    
                                                                {    
                                                                        $Type = ""    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $Type = $item.Type.ToString()    
                                                                }    
                                                                If($Null -eq $item.Location)    
                                                                {    
                                                                        $Location = ""    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $Location = $item.Location    
                                                                }    
                                                        $OptimizationTable += @{    
                                                                Task     = $Task    
                                                                Type     = $Type    
                                                                Location = $Location    
                                                        }    
                                                }    
     
                                                If($OptimizationTable.Count -gt 0)    
                                                {    
                                                        $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                        -Columns Task, Type, Location `    
                                                        -Headers "Task", "Type", "Location" `    
                                                        -Format $wdTableGrid `    
                                                        -AutoFit $wdAutoFitFixed;    
     
                                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                        $Table.Columns.Item(1).Width = 200;    
                                                        $Table.Columns.Item(2).Width = 50;    
                                                        $Table.Columns.Item(3).Width = 250;    
                                                            
                                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                        FindWordDocumentEnd    
                                                        $Table = $Null    
                                                        WriteWordLine 0 0 ""    
                                                }    
                                        }    
                                            
                                        WriteWordLine 5 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled    
                                        If($OPTWindowsAdvancedOptionsEnabled -eq "True")    
                                        {    
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $ScriptInformation.Add(@{Data = "Windows Advanced Options"; Value = ""; }) > $Null    
     
                                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                                -Columns Data,Value `    
                                                -List `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 200;    
                                                $Table.Columns.Item(2).Width = 15;    
     
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
     
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $OptimizationTable = @()    
                            
                                                $OptimizationTable += @{    
                                                        Setting = "Disable Hibernate"    
                                                        Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString()    
                                                        Value   = ""    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Disable Telemetry collection"    
                                                        Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString()    
                                                        Value   = ""    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Disable System Restore"    
                                                        Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString()    
                                                        Value   = ""    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Disable error reporting to send additional data"    
                                                        Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString()    
                                                        Value   = ""    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Disable Tiles"    
                                                        Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString()    
                                                        Value   = ""    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Disable Cortana digital assistant"    
                                                        Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString()    
                                                        Value   = ""    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Turn off Microsoft consumer experience"    
                                                        Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString()    
                                                        Value   = ""    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Do not show Windows tips"    
                                                        Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString()    
                                                        Value   = ""    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Remove Common program groups from the Start Menu"    
                                                        Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString()    
                                                        Value   = ""    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Partial Start Menu layout"    
                                                        Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString()    
                                                        Value   = $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent    
                                                }    
     
                                                If($OptimizationTable.Count -gt 0)    
                                                {    
                                                        $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                        -Columns Setting, Enabled, Value `    
                                                        -Headers "Setting", "Enabled", "Value" `    
                                                        -Format $wdTableGrid `    
                                                        -AutoFit $wdAutoFitFixed;    
     
                                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                        $Table.Columns.Item(1).Width = 275;    
                                                        $Table.Columns.Item(2).Width = 50;    
                                                        $Table.Columns.Item(3).Width = 175;    
                                                            
                                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                        FindWordDocumentEnd    
                                                        $Table = $Null    
                                                        WriteWordLine 0 0 ""    
                                                }    
                                        }    
                                            
                                        WriteWordLine 5 0 "Network performance: " $OPTNetworkPerformanceEnabled    
                                        If($OPTNetworkPerformanceEnabled -eq "True")    
                                        {    
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $ScriptInformation.Add(@{Data = "Network Performance Optimizations"; Value = ""; }) > $Null    
     
                                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                                -Columns Data,Value `    
                                                -List `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 200;    
                                                $Table.Columns.Item(2).Width = 15;    
     
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
     
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $OptimizationTable = @()    
                            
                                                $OptimizationTable += @{    
                                                        Setting = "FileInfoCacheEntriesMax"    
                                                        Enabled = $VDITemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString()    
                                                        Value   = $VDITemplate.Optimization.NetworkPerformance.FileInfoCache    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "DirectoryCacheEntriesMax"    
                                                        Enabled = $VDITemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString()    
                                                        Value   = $VDITemplate.Optimization.NetworkPerformance.DirCacheMax    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "FileNotFoundCacheEntriesMax"    
                                                        Enabled = $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString()    
                                                        Value   = $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCache    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "DormantFileLimit"    
                                                        Enabled = $VDITemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString()    
                                                        Value   = $VDITemplate.Optimization.NetworkPerformance.DormantFileLimit    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Disable TCP/IP Task Offload"    
                                                        Enabled = $VDITemplate.Optimization.NetworkPerformance.DisableTCP.ToString()    
                                                        Value   = ""    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Disable IPv6 Components"    
                                                        Enabled = $VDITemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString()    
                                                        Value   = ""    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Disable IPv6 to IPv4"    
                                                        Enabled = $VDITemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString()    
                                                        Value   = ""    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Disables isatap for IPv6"    
                                                        Enabled = $VDITemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString()    
                                                        Value   = ""    
                                                }    
     
                                                If($OptimizationTable.Count -gt 0)    
                                                {    
                                                        $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                        -Columns Setting, Enabled, Value `    
                                                        -Headers "Setting", "Enabled", "Value" `    
                                                        -Format $wdTableGrid `    
                                                        -AutoFit $wdAutoFitFixed;    
     
                                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                        $Table.Columns.Item(1).Width = 150;    
                                                        $Table.Columns.Item(2).Width = 50;    
                                                        $Table.Columns.Item(3).Width = 50;    
                                                            
                                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                        FindWordDocumentEnd    
                                                        $Table = $Null    
                                                        WriteWordLine 0 0 ""    
                                                }    
                                        }    
     
                                        WriteWordLine 5 0 "Registry: " $OPTRegistryEnabled    
                                        If($OPTRegistryEnabled -eq "True")    
                                        {    
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $ScriptInformation.Add(@{Data = "Registry Optimizations"; Value = ""; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
     
                                                ForEach($item in $VDITemplate.Optimization.Registry.RegistryList)    
                                                {    
                                                        If($item.RegType.ToString() -eq "REG_SZ" -or $item.RegType.ToString() -eq "REG_EXPAND_SZ")    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType.ToString(); }) > $Null    
                                                                $ScriptInformation.Add(@{Data = "Data"; Value = $item.StringValue; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                        }    
                                                        ElseIf($item.RegType.ToString() -eq "REG_DWORD" -or $item.RegType.ToString() -eq "REG_QWORD")    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType.ToString(); }) > $Null    
                                                                $ScriptInformation.Add(@{Data = "Data"; Value = $item.DWORDValue; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                        }    
                                                        ElseIf($item.RegType.ToString() -eq "REG_MULTI_SZ")    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType.ToString(); }) > $Null    
                                                                $cnt = -1    
                                                                $TmpArray = $item.StringValue.Split("`r")    
                                                                ForEach($SubItem in $TmpArray)    
                                                                {    
                                                                        $cnt++    
                                                                            
                                                                        If($cnt -eq 0)    
                                                                        {    
                                                                                $ScriptInformation.Add(@{Data = "Type"; Value = $SubItem; }) > $Null    
                                                                        }    
                                                                        Else    
                                                                        {    
                                                                                $ScriptInformation.Add(@{Data = ""; Value = $SubItem; }) > $Null    
                                                                        }    
                                                                }    
                                                                $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null    
                                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                        }    
                                                }    
     
                                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                                -Columns Data,Value `    
                                                -List `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 125;    
                                                $Table.Columns.Item(2).Width = 375;    
     
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                            
                                        WriteWordLine 5 0 "Visual Effects: " $OPTVisualEffectsEnabled    
                                        If($OPTVisualEffectsEnabled -eq "True")    
                                        {    
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $ScriptInformation.Add(@{Data = "Visual Effects Optimizations"; Value = ""; }) > $Null    
     
                                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                                -Columns Data,Value `    
                                                -List `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 200;    
                                                $Table.Columns.Item(2).Width = 15;    
     
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
     
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $OptimizationTable = @()    
                            
                                                $OptimizationTable += @{    
                                                        Setting = "Animate controls and elements inside windows"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Animate windows when minimizing and maximizing"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Animations in the taskbar"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.AnimateTaskbar.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Enable Peek"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.EnablePeek.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Fade or slide menus into view"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.FadeSlideMenus.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Fade or slide Tooltips into view"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Fade out menu items after clicking"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Save taskbar thumbnail previews"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Show shadows under mouse pointer"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Show shadows under windows"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Show thumbnails instead of icons"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Show translucent selection rectangle"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Show window contents while dragging"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Slide open combo boxes"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Smooth edges of screen fonts"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Smooth-scroll list boxes"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Use drop shadows for icon labels on the desktop"    
                                                        Enabled = $VDITemplate.Optimization.VisualEffects.DropShadowsIcon.ToString()    
                                                }    
     
                                                If($OptimizationTable.Count -gt 0)    
                                                {    
                                                        $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                        -Columns Setting, Enabled `    
                                                        -Headers "Setting", "Enabled" `    
                                                        -Format $wdTableGrid `    
                                                        -AutoFit $wdAutoFitFixed;    
     
                                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                        $Table.Columns.Item(1).Width = 250;    
                                                        $Table.Columns.Item(2).Width = 50;    
                                                            
                                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                        FindWordDocumentEnd    
                                                        $Table = $Null    
                                                        WriteWordLine 0 0 ""    
                                                }    
                                        }    
                                            
                                        WriteWordLine 5 0 "Disk cleanup: " $OPTDiskCleanupEnabled    
                                        If($OPTDiskCleanupEnabled -eq "True")    
                                        {    
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $ScriptInformation.Add(@{Data = "Disk Cleanup Optimizations"; Value = ""; }) > $Null    
     
                                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                                -Columns Data,Value `    
                                                -List `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 200;    
                                                $Table.Columns.Item(2).Width = 15;    
     
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
     
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $OptimizationTable = @()    
                            
                                                $OptimizationTable += @{    
                                                        Setting = "Clean up redundant system files"    
                                                        Enabled = $VDITemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Clean up the WinSxS Folder"    
                                                        Enabled = $VDITemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Clean up temporary files and logs"    
                                                        Enabled = $VDITemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Remove OneDrive"    
                                                        Enabled = $VDITemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString()    
                                                }    
     
                                                $OptimizationTable += @{    
                                                        Setting = "Delete users' profiles"    
                                                        Enabled = $VDITemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString()    
                                                }    
     
                                                If($OptimizationTable.Count -gt 0)    
                                                {    
                                                        $Table = AddWordTable -Hashtable $OptimizationTable `    
                                                        -Columns Setting, Enabled `    
                                                        -Headers "Setting", "Enabled" `    
                                                        -Format $wdTableGrid `    
                                                        -AutoFit $wdAutoFitFixed;    
     
                                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                        $Table.Columns.Item(1).Width = 175;    
                                                        $Table.Columns.Item(2).Width = 50;    
                                                            
                                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                        FindWordDocumentEnd    
                                                        $Table = $Null    
                                                        WriteWordLine 0 0 ""    
                                                }    
                                        }    
     
                                        WriteWordLine 5 0 "Custom script: " $OPTCustomScriptEnabled    
                                        If($OPTCustomScriptEnabled -eq "True")    
                                        {    
                                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                                $ScriptInformation.Add(@{Data = "Custom Script"; Value = ""; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "     Command"; Value = $VDITemplate.Optimization.CustomScript.Command; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "     Arguments"; Value = $VDITemplate.Optimization.CustomScript.Arguments; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "     Initial directory"; Value = $VDITemplate.Optimization.CustomScript.InitDir; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "     Username"; Value = $VDITemplate.Optimization.CustomScript.User; }) > $Null    
     
                                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                                -Columns Data,Value `    
                                                -List `    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 100;    
                                                $Table.Columns.Item(2).Width = 200;    
     
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
                                }    
                                If($Text)    
                                {    
                                        Line 3 "Inherit default settings`t: " $VDITemplate.InheritDefaultOptimizationSettings.ToString()    
                                        Line 3 "Enable optimization`t`t: " $OPTEnableOptimization    
                                        Line 3 "Optimization type`t`t: " $OPTOptimizationType    
                                        Line 3 "Category"    
                                            
                                        Line 4 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled    
                                        If($OPTWindowsDefenderATPEnabled -eq "True")    
                                        {    
                                                Line 5 "Windows Defender ATP Optimizations"    
                                                If($VDITemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")    
                                                {    
                                                        Line 6 "Turn off Windows Defender ATP (I use my own ATP solution)"    
                                                }    
                                                Else    
                                                {    
                                                        Line 6 "Turn on Windows Defender ATP and set process and folder exclusions"    
                                                        Line 6 "Disable real-time protection: " $VDITemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString()    
                                                        Line 0 ""    
                                                        Line 6 "Exclude files and folders:"    
                                                        ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeFolders)    
                                                        {    
                                                                Line 7 $item    
                                                        }    
     
                                                        Line 6 "Exclude processes:"    
                                                        ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)    
                                                        {    
                                                                Line 7 $item    
                                                        }    
                                                            
                                                        Line 6 "Exclude extensions:"    
                                                        ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeExtension)    
                                                        {    
                                                                Line 7 $item    
                                                        }    
                                                }    
                                                    
                                                Line 0 ""    
                                        }    
                                            
                                        Line 4 "Windows Components: " $OPTWindowsComponentsEnabled    
                                        If($OPTWindowsComponentsEnabled -eq "True")    
                                        {    
                                                Line 5 "Windows Components Optimizations"    
                                                Line 6 "Disable (remove) components:"    
                                                Line 0 ""    
                                                Line 6 "Display name                                        Component                                         "    
                                                Line 6 "======================================================================================================"    
                                                #               12345678901234567890123456789012345678901234567890SS12345678901234567890123456789012345678901234567890    
                                                #               Printing-XPSServices-Features                       SMB 1.0/CIFS File sharing support component    
                                                ForEach($item in $VDITemplate.Optimization.WindowsComponents.WindowsComponentsList)    
                                                {    
                                                        Line 6 ( "{0,-50}  {1,-50}" -f $item.DisplayName, $item.ComponentName)    
                                                }    
                                                Line 0 ""    
                                        }    
                                            
                                        Line 4 "Windows Services: " $OPTWindowsServicesEnabled           
                                        If($OPTWindowsServicesEnabled -eq "True")    
                                        {    
                                                Line 5 "Windows Services Optimizations"    
                                                Line 6 "Disable services:"    
                                                Line 0 ""    
                                                Line 6 "Display name                                        Service                         Aliases             "    
                                                Line 6 "========================================================================================================"    
                                                #               12345678901234567890123456789012345678901234567890SS123456789012345678901234567890SS12345678901234567890    
                                                #               Windows Media Player Network Sharing Service        TabletInputService              Superfecth    
                                                ForEach($item in $VDITemplate.Optimization.WindowsServices.WindowsServicesList)    
                                                {    
                                                        Line 6 ( "{0,-50}  {1,-30}  {2,-20}" -f $item.DisplayName, $item.ServiceName, $item.Aliases)    
                                                }    
                                                Line 0 ""    
                                        }    
                                            
                                        Line 4 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled     
                                        If($OPTWinodwsScheduledTasksEnabled -eq "True")    
                                        {    
                                                Line 5 "Windows Scheduled Tasks Optimizations"    
                                                Line 6 "Disable tasks:"    
                                                Line 0 ""    
                                                Line 6 "Task                                                Type    Location                                          "    
                                                Line 6 "=============================================================================================================="    
                                                #               12345678901234567890123456789012345678901234567890SS123456SS12345678901234567890123456789012345678901234567890    
                                                #               MNO Metadata Parser                                 Folder  \Microsoft\Windows\Mobile Broadband Accounts\    
                                                ForEach($item in $VDITemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)    
                                                {    
                                                        Line 6 ( "{0,-50}  {1,-6}  {2,-50}" -f $item.Task, $item.Type.ToString(), $item.Location)    
                                                }    
                                                Line 0 ""    
                                        }    
     
                                        Line 4 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled    
                                        If($OPTWindowsAdvancedOptionsEnabled -eq "True")    
                                        {    
                                                Line 5 "Windows Advanced Options"    
                                                Line 0 ""    
                                                Line 6 "Setting                                           Enabled  Value                                             "    
                                                Line 6 "============================================================================================================="    
                                                #               123456789012345678901234567890123456789012345678SS1234567SS12345678901234567890123456789012345678901234567890    
                                                #               Remove Common program groups from the start menu  False    SomeConfigFile.xml    
                                                Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                                "Disable Hibernate", `    
                                                $VDITemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString(), `    
                                                "")    
                                                    
                                                Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                                "Disable Telemetry collection", `    
                                                $VDITemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(), `    
                                                "")    
                                                    
                                                Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                                "Disable System Restore", `    
                                                $VDITemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(), `    
                                                "")    
                                                    
                                                Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                                "Disable error reporting to send additional data", `    
                                                $VDITemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(), `    
                                                "")    
                                                    
                                                Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                                "Disable Tiles", `    
                                                $VDITemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString(), `    
                                                "")    
                                                    
                                                Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                                "Disable Cortana digital assistant", `    
                                                $VDITemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString(), `    
                                                "")    
                                                    
                                                Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                                "Turn off Microsoft consumer experience", `    
                                                $VDITemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(), `    
                                                "")    
                                                    
                                                Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                                "Do not show Windows tips", `    
                                                $VDITemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(), `    
                                                "")    
                                                    
                                                Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                                "Remove Common program groups from the Start Menu", `    
                                                $VDITemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(), `    
                                                "")    
                                                    
                                                Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `    
                                                "Partial Start Menu layout", `    
                                                $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(), `    
                                                $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent)    
                                                    
                                                Line 0 ""    
                                        }    
     
                                        Line 4 "Network performance: " $OPTNetworkPerformanceEnabled    
                                        If($OPTNetworkPerformanceEnabled -eq "True")    
                                        {    
                                                Line 5 "Network Performance Optimizations"    
                                                Line 0 ""    
                                                Line 6 "Setting                      Enabled  Value"    
                                                Line 6 "==========================================="    
                                                #               123456789012345678901234567SS1234567SS12345    
                                                #               FileNotFoundCacheEntriesMax  False    32768    
                                                Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                                "FileInfoCacheEntriesMax", `    
                                                $VDITemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(), `    
                                                $VDITemplate.Optimization.NetworkPerformance.FileInfoCache)    
                                                    
                                                Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                                "DirectoryCacheEntriesMax", `    
                                                $VDITemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(), `    
                                                $VDITemplate.Optimization.NetworkPerformance.DirCacheMax)    
                                                    
                                                Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                                "FileNotFoundCacheEntriesMax", `    
                                                $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(), `    
                                                $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCache)    
                                                    
                                                Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                                "DormantFileLimit", `    
                                                $VDITemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(), `    
                                                $VDITemplate.Optimization.NetworkPerformance.DormantFileLimit)    
                                                    
                                                Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                                "Disable TCP/IP Task Offload", `    
                                                $VDITemplate.Optimization.NetworkPerformance.DisableTCP.ToString(), `    
                                                "")    
                                                    
                                                Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                                "Disable IPv6 Components", `    
                                                $VDITemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(), `    
                                                "")    
                                                    
                                                Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                                "Disable IPv6 to IPv4", `    
                                                $VDITemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(), `    
                                                "")    
                                                    
                                                Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `    
                                                "Disables isatap for IPv6", `    
                                                $VDITemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString(), `    
                                                "")    
                                                    
                                                Line 0 ""    
                                        }    
     
                                        Line 4 "Registry: " $OPTRegistryEnabled    
                                        If($OPTRegistryEnabled -eq "True")    
                                        {    
                                                Line 5 "Registry Optimizations"    
                                                Line 0 ""    
                                                #               123456789012345678901234567SS1234567SS12345    
                                                #               FileNotFoundCacheEntriesMax  False    32768    
                                                Line 6 "Registry                                  Action  Value                 Type           Data                  Path                                                        "    
                                                Line 6 "========================================================================================================================================================================="    
                                                #               1234567890123456789012345678901234567890SS123456SS12345678901234567890SS1234567890123SS12345678901234567890SS123456789012345678901234567890123456789012345678901234567890    
                                                #               Increase service startup timeouts         Modify  99999999999999999999  REG_EXPAND_SZ  99999999999999999999  HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Disk    
                                                ForEach($item in $RDSHost.Optimization.Registry.RegistryList)    
                                                {    
                                                        If($item.RegType.ToString() -eq "REG_SZ" -or $item.RegType.ToString() -eq "REG_EXPAND_SZ")    
                                                        {    
                                                                Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `    
                                                                $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType.ToString(), $item.StringValue, "$($item.HiveType)\$($item.Path)")    
                                                        }    
                                                        ElseIf($item.RegType.ToString() -eq "REG_DWORD" -or $item.RegType.ToString() -eq "REG_QWORD")    
                                                        {    
                                                                Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `    
                                                                $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType.ToString(), $item.DWORDValue, "$($item.HiveType)\$($item.Path)")    
                                                        }    
                                                        ElseIf($item.RegType.ToString() -eq "REG_MULTI_SZ")    
                                                        {    
                                                                #If($item.StringValue.Count -eq 1)    
                                                                #{    
                                                                #       Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `    
                                                                #       $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType.ToString(), $item.StringValue.ToString(), "$($item.HiveType)\$($item.Path)")    
                                                                #}    
                                                                #Else    
                                                                #{    
                                                                        $cnt = -1    
                                                                        $TmpArray = $item.StringValue.Split("`r")    
                                                                        ForEach($SubItem in $TmpArray)    
                                                                        {    
                                                                                $cnt++    
                                                                                    
                                                                                If($cnt -eq 0)    
                                                                                {    
                                                                                        Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `    
                                                                                        $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType.ToString(), $SubItem, "$($item.HiveType)\$($item.Path)")    
                                                                                }    
                                                                                Else    
                                                                                {    
                                                                                        Line 17 "       " $SubItem    
                                                                                }    
                                                                        }    
                                                                #}    
                                                        }    
                                                }    
                                                Line 0 ""    
                                        }    
     
                                        Line 4 "Visual Effects: " $OPTVisualEffectsEnabled    
                                        If($OPTVisualEffectsEnabled -eq "True")    
                                        {    
                                                Line 5 "Visual Effects Optimizations"    
                                                Line 0 ""    
                                                    
                                                Switch ($VDITemplate.Optimization.VisualEffects.VisualEffectsTypes)    
                                                {    
                                                        "LetWindowsChooseWhatsBest"     {$VisualEffectsType = "Let Windows choose what's best"; Break}    
                                                        "AdjustForBestAppearnce"        {$VisualEffectsType = "Adjust for best appearance"; Break} #misspelled in the PoSH output and the docs    
                                                        "AdjustForBestPerformance"      {$VisualEffectsType = "Adjust for best performance"; Break}    
                                                        "Custom"                                        {$VisualEffectsType = "Custom"; Break}    
                                                        Default                                         {$VisualEffectsType = "Unable to determine Visual Effects Optimization type: $($VDITemplate.Optimization.VisualEffects.VisualEffectsTypes)"; Break}    
                                                }    
                                                Line 6 $VisualEffectsType    
                                                Line 0 ""    
                                                Line 6 "Setting                                             Enabled"    
                                                Line 6 "==========================================================="    
                                                #               12345678901234567890123456789012345678901234567890SS1234567    
                                                #               Use drop shadows for icon labels on the desktop     False      
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Animate controls and elements inside windows", `    
                                                $VDITemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Animate windows when minimizing and maximizing", `    
                                                $VDITemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Animations in the taskbar", `    
                                                $VDITemplate.Optimization.VisualEffects.AnimateTaskbar.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Enable Peek", `    
                                                $VDITemplate.Optimization.VisualEffects.EnablePeek.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Fade or slide menus into view", `    
                                                $VDITemplate.Optimization.VisualEffects.FadeSlideMenus.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Fade or slide Tooltips into view", `    
                                                $VDITemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Fade out menu items after clicking", `    
                                                $VDITemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Save taskbar thumbnail previews", `    
                                                $VDITemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Show shadows under mouse pointer", `    
                                                $VDITemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Show shadows under windows", `    
                                                $VDITemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Show thumbnails instead of icons", `    
                                                $VDITemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Show translucent selection rectangle", `    
                                                $VDITemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Show window contents while dragging", `    
                                                $VDITemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Slide open combo boxes", `    
                                                $VDITemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Smooth edges of screen fonts", `    
                                                $VDITemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Smooth-scroll list boxes", `    
                                                $VDITemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString())    
                                                    
                                                Line 6 ( "{0,-50}  {1,-7}" -f `    
                                                "Use drop shadows for icon labels on the desktop", `    
                                                $VDITemplate.Optimization.VisualEffects.DropShadowsIcon.ToString())    
                                                    
                                                Line 0 ""    
                                        }    
     
                                        Line 4 "Disk cleanup: " $OPTDiskCleanupEnabled    
                                        If($OPTDiskCleanupEnabled -eq "True")    
                                        {    
                                                Line 5 "Disk Cleanup Optimizations"    
                                                Line 0 ""    
                                                    
                                                Line 6 "Setting                            Enabled"    
                                                Line 6 "=========================================="    
                                                #               123456789012345678901234567890123SS1234567    
                                                #               Clean up temporary files and logs  False      
                                                Line 6 ( "{0,-33}  {1,-7}" -f `    
                                                "Clean up redundant system files", `    
                                                $VDITemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString())    
                                                    
                                                Line 6 ( "{0,-33}  {1,-7}" -f `    
                                                "Clean up the WinSxS Folder", `    
                                                $VDITemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString())    
                                                    
                                                Line 6 ( "{0,-33}  {1,-7}" -f `    
                                                "Clean up temporary files and logs", `    
                                                $VDITemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString())    
                                                    
                                                Line 6 ( "{0,-33}  {1,-7}" -f `    
                                                "Remove OneDrive", `    
                                                $VDITemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString())    
                                                    
                                                Line 6 ( "{0,-33}  {1,-7}" -f `    
                                                "Delete users' profiles", `    
                                                $VDITemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString())    
                                                    
                                                Line 0 ""    
                                        }    
     
                                        Line 4 "Custom script: " $OPTCustomScriptEnabled    
                                        If($OPTCustomScriptEnabled  -eq "True")    
                                        {    
                                                Line 5 "Custom Script"    
                                                Line 0 ""    
                                                    
                                                Line 6 "Command`t`t : " $VDITemplate.Optimization.CustomScript.Command    
                                                Line 6 "Arguments`t : " $VDITemplate.Optimization.CustomScript.Arguments    
                                                Line 6 "Initial directory: " $VDITemplate.Optimization.CustomScript.InitDir    
                                                Line 6 "Username`t : " $VDITemplate.Optimization.CustomScript.User    
                                                Line 0 ""    
                                        }    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Inherit default settings:",($Script:htmlsb),$VDITemplate.InheritDefaultOptimizationSettings.ToString(),$htmlwhite)    
                                        $rowdata += @(,("Enable optimization:",($Script:htmlsb), $OPTEnableOptimization,$htmlwhite))    
                                        $rowdata += @(,("Optimization type:",($Script:htmlsb), $OPTOptimizationType,$htmlwhite))    
     
                                        $msg = "Optimization"    
                                        $columnWidths = @("300","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
     
                                        WriteHTMLLine 4 0 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled    
                                        If($OPTWindowsDefenderATPEnabled -eq "True")    
                                        {    
                                                $rowdata = @()    
                                                $columnHeaders = @("Windows Defender ATP Optimizations",($Script:htmlsb),"",$htmlwhite)    
     
                                                If($VDITemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")    
                                                {    
                                                        $rowdata += @(,("     Turn off Windows Defender ATP (I use my own ATP solution)",($Script:htmlsb), "",$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("     Turn on Windows Defender ATP and set process and folder exclusions",($Script:htmlsb), "",$htmlwhite))    
                                                        $rowdata += @(,("     Disable real-time protection",($Script:htmlsb), $VDITemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(),$htmlwhite))    
                                                        $rowdata += @(,("",($Script:htmlsb), "",$htmlwhite))    
                                                            
                                                        $cnt = -1    
                                                        ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeFolders)    
                                                        {    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $rowdata += @(,("     Exclude files and folders",($Script:htmlsb), $item,$htmlwhite))    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))    
                                                                }    
                                                        }    
     
                                                        $cnt = -1    
                                                        ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)    
                                                        {    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $rowdata += @(,("     Exclude processes",($Script:htmlsb), $item,$htmlwhite))    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))    
                                                                }    
                                                        }    
                                                            
                                                        $cnt = -1    
                                                        ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeExtension)    
                                                        {    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $rowdata += @(,("     Exclude extensions",($Script:htmlsb), $item,$htmlwhite))    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))    
                                                                }    
                                                        }    
                                                }    
     
     
                                                $msg = ""    
                                                $columnWidths = @("300","275")    
                                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                                WriteHTMLLine 0 0 ""    
                                        }    
     
                                        WriteHTMLLine 4 0 "Windows Components: " $OPTWindowsComponentsEnabled    
                                        If($OPTWindowsComponentsEnabled -eq "True")    
                                        {    
                                                WriteHTMLLine 0 0 "Windows Components Optimizations"    
     
                                                $rowdata = @()    
     
                                                ForEach($item in $VDITemplate.Optimization.WindowsComponents.WindowsComponentsList)    
                                                {    
                                                        $rowdata += @(,(    
                                                                $item.DisplayName,$htmlwhite,    
                                                                $item.ComponentName,$htmlwhite)    
                                                        )    
                                                }    
     
                                                $columnHeaders = @(    
                                                        "Display Name",($Script:htmlsb),    
                                                        "Component",($Script:htmlsb)    
                                                )    
     
                                                $msg = "Disable (remove) components:"    
                                                $columnWidths = @("200","200")    
                                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                                WriteHTMLLine 0 0 ""    
                                        }    
     
                                        WriteHTMLLine 4 0 "Windows Services: " $OPTWindowsServicesEnabled           
                                        If($OPTWindowsServicesEnabled -eq "True")    
                                        {    
                                                WriteHTMLLine 0 0 "Windows Services Optimizations"    
     
                                                $rowdata = @()    
     
                                                ForEach($item in $VDITemplate.Optimization.WindowsServices.WindowsServicesList)    
                                                {    
                                                        $rowdata += @(,(    
                                                                $item.DisplayName,$htmlwhite,    
                                                                $item.ServiceName,$htmlwhite,    
                                                                $item.Aliases,$htmlwhite)    
                                                        )    
                                                }    
     
                                                $columnHeaders = @(    
                                                        "Display Name",($Script:htmlsb),    
                                                        "Service",($Script:htmlsb),    
                                                        "Aliases",($Script:htmlsb)    
                                                )    
     
                                                $msg = "Disable services:"    
                                                $columnWidths = @("200","100","50")    
                                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                                WriteHTMLLine 0 0 ""    
                                        }    
     
                                        WriteHTMLLine 4 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled    
                                        If($OPTWinodwsScheduledTasksEnabled -eq "True")    
                                        {    
                                                WriteHTMLLine 0 0 "Windows Scheduled Tasks Optimizations"    
     
                                                $rowdata = @()    
     
                                                ForEach($item in $VDITemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)    
                                                {    
                                                        $rowdata += @(,(    
                                                                $item.Task,$htmlwhite,    
                                                                $item.Type.Tostring(),$htmlwhite,    
                                                                $item.Location,$htmlwhite)    
                                                        )    
                                                }    
     
                                                $columnHeaders = @(    
                                                        "Task",($Script:htmlsb),    
                                                        "Type",($Script:htmlsb),    
                                                        "Location",($Script:htmlsb)    
                                                )    
     
                                                $msg = "Disable tasks:"    
                                                $columnWidths = @("200","50","250")    
                                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                                WriteHTMLLine 0 0 ""    
                                        }    
     
                                        WriteHTMLLine 4 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled    
                                        If($OPTWindowsAdvancedOptionsEnabled -eq "True")    
                                        {    
                                                WriteHTMLLine 0 0 "Windows Advanced Options"    
     
                                                $rowdata = @()    
     
                                                $rowdata += @(,(    
                                                        "Disable Hibernate",$htmlwhite,    
                                                        $VDITemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString(),$htmlwhite,    
                                                        "",$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Disable Telemetry collection",$htmlwhite,    
                                                        $VDITemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(),$htmlwhite,    
                                                        "",$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Disable System Restore",$htmlwhite,    
                                                        $VDITemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(),$htmlwhite,    
                                                        "",$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Disable error reporting to send additional data",$htmlwhite,    
                                                        $VDITemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(),$htmlwhite,    
                                                        "",$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Disable Tiles",$htmlwhite,    
                                                        $VDITemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString(),$htmlwhite,    
                                                        "",$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Disable Cortana digital assistant",$htmlwhite,    
                                                        $VDITemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString(),$htmlwhite,    
                                                        "",$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Turn off Microsoft consumer experience",$htmlwhite,    
                                                        $VDITemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(),$htmlwhite,    
                                                        "",$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Do not show Windows tips",$htmlwhite,    
                                                        $VDITemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(),$htmlwhite,    
                                                        "",$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Remove Common program groups from the Start Menu",$htmlwhite,    
                                                        $VDITemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(),$htmlwhite,    
                                                        "",$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Partial Start Menu layout",$htmlwhite,    
                                                        $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(),$htmlwhite,    
                                                        $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent,$htmlwhite)    
                                                )    
     
                                                $columnHeaders = @(    
                                                        "Setting",($Script:htmlsb),    
                                                        "Enabled",($Script:htmlsb),    
                                                        "Value",($Script:htmlsb)    
                                                )    
     
                                                $msg = ""    
                                                $columnWidths = @("300","50","200")    
                                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                                WriteHTMLLine 0 0 ""    
                                        }    
     
                                        WriteHTMLLine 4 0 "Network performance: " $OPTNetworkPerformanceEnabled    
                                        If($OPTWindowsAdvancedOptionsEnabled -eq "True")    
                                        {    
                                                WriteHTMLLine 0 0 "Network Performance Optimizations"    
     
                                                $rowdata = @()    
     
                                                $rowdata += @(,(    
                                                        "FileInfoCacheEntriesMax",$htmlwhite,    
                                                        $VDITemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(),$htmlwhite,    
                                                        $VDITemplate.Optimization.NetworkPerformance.FileInfoCache,$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "DirectoryCacheEntriesMax",$htmlwhite,    
                                                        $VDITemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(),$htmlwhite,    
                                                        $VDITemplate.Optimization.NetworkPerformance.DirCacheMax,$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "FileNotFoundCacheEntriesMax",$htmlwhite,    
                                                        $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(),$htmlwhite,    
                                                        $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCache,$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "DormantFileLimit",$htmlwhite,    
                                                        $VDITemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(),$htmlwhite,    
                                                        $VDITemplate.Optimization.NetworkPerformance.DormantFileLimit,$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Disable TCP/IP Task Offload",$htmlwhite,    
                                                        $VDITemplate.Optimization.NetworkPerformance.DisableTCP.ToString(),$htmlwhite,    
                                                        "",$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Disable IPv6 Components",$htmlwhite,    
                                                        $VDITemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(),$htmlwhite,    
                                                        "",$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Disable IPv6 to IPv4",$htmlwhite,    
                                                        $VDITemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(),$htmlwhite,    
                                                        "",$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Disables isatap for IPv6",$htmlwhite,    
                                                        $VDITemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString(),$htmlwhite,    
                                                        "",$htmlwhite)    
                                                )    
     
                                                $columnHeaders = @(    
                                                        "Setting",($Script:htmlsb),    
                                                        "Enabled",($Script:htmlsb),    
                                                        "Value",($Script:htmlsb)    
                                                )    
     
                                                $msg = ""    
                                                $columnWidths = @("170","50","50")    
                                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                                WriteHTMLLine 0 0 ""    
                                        }    
     
                                        WriteHTMLLine 4 0 "Registry: " $OPTRegistryEnabled           
                                        If($OPTRegistryEnabled -eq "True")    
                                        {    
                                                WriteHTMLLine 0 0 "Registry Optimizations"    
     
                                                $rowdata = @()    
     
                                                ForEach($item in $VDITemplate.Optimization.Registry.RegistryList)    
                                                {    
                                                        If($item.RegType.ToString() -eq "REG_SZ" -or $item.RegType.ToString() -eq "REG_EXPAND_SZ")    
                                                        {    
                                                                $rowdata += @(,(    
                                                                        $item.DisplayName,$htmlwhite,    
                                                                        $item.Action,$htmlwhite,    
                                                                        $item.RegistryName,$htmlwhite,    
                                                                        $item.RegType.ToString(),$htmlwhite,    
                                                                        $item.StringValue,$htmlwhite,    
                                                                        "$($item.HiveType)\$($item.Path)",$htmlwhite)    
                                                                )    
                                                        }    
                                                        ElseIf($item.RegType.ToString() -eq "REG_DWORD" -or $item.RegType.ToString() -eq "REG_QWORD")    
                                                        {    
                                                                $rowdata += @(,(    
                                                                        $item.DisplayName,$htmlwhite,    
                                                                        $item.Action,$htmlwhite,    
                                                                        $item.RegistryName,$htmlwhite,    
                                                                        $item.RegType.ToString(),$htmlwhite,    
                                                                        $item.DWORDValue,$htmlwhite,    
                                                                        "$($item.HiveType)\$($item.Path)",$htmlwhite)    
                                                                )    
                                                        }    
                                                        ElseIf($item.RegType.ToString() -eq "REG_MULTI_SZ")    
                                                        {    
                                                                $rowdata += @(,(    
                                                                        $item.DisplayName,$htmlwhite,    
                                                                        $item.Action,$htmlwhite,    
                                                                        $item.RegistryName,$htmlwhite,    
                                                                        $item.RegType.ToString(),$htmlwhite,    
                                                                        $item.StringValue.ToString(),$htmlwhite,    
                                                                        "$($item.HiveType)\$($item.Path)",$htmlwhite)    
                                                                )    
                                                        }    
                                                }    
     
                                                $columnHeaders = @(    
                                                        "Registry",($Script:htmlsb),    
                                                        "Action",($Script:htmlsb),    
                                                        "Value",($Script:htmlsb),    
                                                        "Type",($Script:htmlsb),    
                                                        "Data",($Script:htmlsb),    
                                                        "Path",($Script:htmlsb)    
                                                )    
     
                                                $msg = ""    
                                                $columnWidths = @("200","50","100","100","100","200")    
                                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                                WriteHTMLLine 0 0 ""    
                                        }    
     
                                        WriteHTMLLine 4 0 "Visual Effects: " $OPTVisualEffectsEnabled    
                                        If($OPTVisualEffectsEnabled -eq "True")    
                                        {    
                                                WriteHTMLLine 0 0 "Visual Effects Optimizations"    
     
                                                $rowdata = @()    
     
                                                $rowdata += @(,(    
                                                        "Animate controls and elements inside windows",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Animate windows when minimizing and maximizing",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Animations in the taskbar",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.AnimateTaskbar.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Enable Peek",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.EnablePeek.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Fade or slide menus into view",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.FadeSlideMenus.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Fade or slide Tooltips into view",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Fade out menu items after clicking",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Save taskbar thumbnail previews",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Show shadows under mouse pointer",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Show shadows under windows",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Show thumbnails instead of icons",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Show translucent selection rectangle",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Show window contents while dragging",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Slide open combo boxes",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Smooth edges of screen fonts",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Smooth-scroll list boxes",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Use drop shadows for icon labels on the desktop",$htmlwhite,    
                                                        $VDITemplate.Optimization.VisualEffects.DropShadowsIcon.ToString(),$htmlwhite)    
                                                )    
     
                                                $columnHeaders = @(    
                                                        "Setting",($Script:htmlsb),    
                                                        "Enabled",($Script:htmlsb)    
                                                )    
     
                                                $msg = ""    
                                                $columnWidths = @("275","50")    
                                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                                WriteHTMLLine 0 0 ""    
                                        }    
     
                                        WriteHTMLLine 4 0 "Disk cleanup: " $OPTDiskCleanupEnabled    
                                        If($OPTDiskCleanupEnabled -eq "True")    
                                        {    
                                                WriteHTMLLine 0 0 "Disk Cleanup Optimizations"    
     
                                                $rowdata = @()    
     
                                                $rowdata += @(,(    
                                                        "Clean up redundant system files",$htmlwhite,    
                                                        $VDITemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Clean up the WinSxS Folder",$htmlwhite,    
                                                        $VDITemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Clean up temporary files and logs",$htmlwhite,    
                                                        $VDITemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Remove OneDrive",$htmlwhite,    
                                                        $VDITemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString(),$htmlwhite)    
                                                )    
     
                                                $rowdata += @(,(    
                                                        "Delete users' profiles",$htmlwhite,    
                                                        $VDITemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString(),$htmlwhite)    
                                                )    
     
                                                $columnHeaders = @(    
                                                        "Setting",($Script:htmlsb),    
                                                        "Enabled",($Script:htmlsb)    
                                                )    
     
                                                $msg = ""    
                                                $columnWidths = @("200","50")    
                                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                                WriteHTMLLine 0 0 ""    
                                        }    
     
                                        WriteHTMLLine 4 0 "Custom script: " $OPTCustomScriptEnabled    
                                        If($OPTCustomScriptEnabled -eq "True")    
                                        {    
                                                $rowdata = @()    
                                                $columnHeaders = @("Custom Script",($Script:htmlsb),"",$htmlwhite)    
                                                $rowdata += @(,("     Command",($Script:htmlsb), $VDITemplate.Optimization.CustomScript.Command,$htmlwhite))    
                                                $rowdata += @(,("     Arguments",($Script:htmlsb), $VDITemplate.Optimization.CustomScript.Arguments,$htmlwhite))    
                                                $rowdata += @(,("     Initial directory",($Script:htmlsb), $VDITemplate.Optimization.CustomScript.InitDir,$htmlwhite))    
                                                $rowdata += @(,("     Username",($Script:htmlsb), $VDITemplate.Optimization.CustomScript.User,$htmlwhite))    
     
                                                $msg = ""    
                                                $columnWidths = @("125","200")    
                                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                                WriteHTMLLine 0 0 ""    
                                        }    
                                }    
     
 
                                                Line 4 "License key management type: " "Key Management Service (KMS)" <>                                                 Line 4 "License key management type`t: " "Key Management Service (KMS)"
 
                                                Line 4 "License key management type: " "Multple Activation Key (MAK)" <>                                                 Line 4 "License key management type`t`t`t: " "Multple Activation Key (MAK)"
 
                                 <>  
                                #Settings    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 4 0 "Settings"    
                                }                           }
                                If($Text)    
                                {    
                                        Line 3 "Settings"    
                                }                   }
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
                                    
                                If($VDITemplate.InheritDefaultVDIActionSettings)    
                                {    
                                        #do we inherit site defaults?    
                                        #yes we do, get the default settings for the Site    
                                        #use the Site default settings    
     
                                        $VDIDefaults = Get-RASVDIDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                            
                                        If($? -and $Null -ne $VDIDefaults)                   ElseIf($? -and $Null -eq $VDITemplates)
                                        {                   {
                                                Switch ($VDIDefaults.SessionResetTimeoutSec)                           If($MSWord -or $PDF)
                                                {                           {
                                                        0               {$VDITemplateLogoffActiveSessionAfter = "Never"; Break}    
                                                        1               {$VDITemplateLogoffActiveSessionAfter = "Immediate"; Break}    
                                                        25              {$VDITemplateLogoffActiveSessionAfter = "25 seconds"; Break}    
                                                        60              {$VDITemplateLogoffActiveSessionAfter = "1 minute"; Break}    
                                                        300             {$VDITemplateLogoffActiveSessionAfter = "5 minutes"; Break}                                   WriteWordLine 0 0 "No VDI Templates found for Site $($Site.Name)"
                                                        3600    {$VDITemplateLogoffActiveSessionAfter = "1 hour"; Break}                                   WriteWordLine 0 0 ""
                                                        7200    {$VDITemplateLogoffActiveSessionAfter = "2 hours"; Break}    
                                                        Default {$VDITemplateLogoffActiveSessionAfter = "Unable to determine Logoff active session after: $($VDIDefaults.SessionResetTimeoutSec)"; Break}    
                                                }                           }
                                                                          If($Text)
                                                Switch ($VDIDefaults.PerformActionAfterSec)    
                                                {                           {
                                                        0               {$VDITemplateActionsAfter = "Never"; Break}    
                                                        1               {$VDITemplateActionsAfter = "Immediate"; Break}    
                                                        25              {$VDITemplateActionsAfter = "25 seconds"; Break}    
                                                        60              {$VDITemplateActionsAfter = "1 minute"; Break}                                   Line 0 "No VDI Templates found for Site $($Site.Name)"
                                                        300             {$VDITemplateActionsAfter = "5 minutes"; Break}    
                                                        3600    {$VDITemplateActionsAfter = "1 hour"; Break}    
                                                        7200    {$VDITemplateActionsAfter = "2 hours"; Break}    
                                                        Default {$VDITemplateActionsAfter = "Unable to determine Actions After: $($VDIDefaults.PerformActionAfterSec)"; Break}    
                                                }                                   Line 0 ""
                                                $VDITemplateActionsOnSession         = $VDIDefaults.SessionAction.ToString()    
                                                $VDITemplateActionsPerformAction     = $VDIDefaults.PerformAction.ToString()    
                                        }                           }
                                        Else                           If($HTML)
                                        {                           {
                                                #unable to retrieve default, use built-in default values    
                                                $VDITemplateLogoffActiveSessionAfter = "Never"                                   WriteHTMLLine 0 0 "No VDI Templates found for Site $($Site.Name)"
                                                $VDITemplateActionsOnSession         = "Disconnect"                                   WriteHTMLLine 0 0 ""
                                                $VDITemplateActionsPerformAction     = "Do nothing"    
                                                $VDITemplateActionsAfter             = "Never"    
                                        }                           }
                                }                   }
                                Else                   Else
                                {                   {
                                        #No, we don't use the VDI Template settings    
                                        Switch ($VDITemplate.SessionResetTimeoutSec)    
                                        {    
                                                0               {$VDITemplateLogoffActiveSessionAfter = "Never"; Break}    
                                                1               {$VDITemplateLogoffActiveSessionAfter = "Immediate"; Break}    
                                                25              {$VDITemplateLogoffActiveSessionAfter = "25 seconds"; Break}    
                                                60              {$VDITemplateLogoffActiveSessionAfter = "1 minute"; Break}    
                                                300             {$VDITemplateLogoffActiveSessionAfter = "5 minutes"; Break}    
                                                3600    {$VDITemplateLogoffActiveSessionAfter = "1 hour"; Break}    
                                                7200    {$VDITemplateLogoffActiveSessionAfter = "2 hours"; Break}    
                                                Default {$VDITemplateLogoffActiveSessionAfter = "Unable to determine Logoff active session after: $($VDITemplate.SessionResetTimeoutSec)"; Break}    
                                        }    
                                            
                                        Switch ($VDITemplate.PerformActionAfterSec)    
                                        {    
                                                0               {$VDITemplateActionsAfter = "Never"; Break}    
                                                1               {$VDITemplateActionsAfter = "Immediate"; Break}    
                                                25              {$VDITemplateActionsAfter = "25 seconds"; Break}    
                                                60              {$VDITemplateActionsAfter = "1 minute"; Break}    
                                                300             {$VDITemplateActionsAfter = "5 minutes"; Break}    
                                                3600    {$VDITemplateActionsAfter = "1 hour"; Break}    
                                                7200    {$VDITemplateActionsAfter = "2 hours"; Break}    
                                                Default {$VDITemplateActionsAfter = "Unable to determine Actions After: $($VDITemplate.PerformActionAfterSec)"; Break}    
                                        }    
                                        $VDITemplateActionsOnSession         = $VDITemplate.SessionAction.ToString()    
                                        $VDITemplateActionsPerformAction     = $VDITemplate.PerformAction.ToString()    
                                }    
                                    
                                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                                {                           {
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefaultVDIActionSettings.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Application session lingering"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Logoff active session after"; Value = $VDITemplateLogoffActiveSessionAfter; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Actions"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     On session"; Value = $VDITemplateActionsOnSession; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Perform action"; Value = $VDITemplateActionsPerformAction; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     After"; Value = $VDITemplateActionsAfter; }) > $Null                                   WriteWordLine 0 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                                }                           }
                                If($Text)                           If($Text)
                                {                           {
                                        Line 4 "Inherit default settings`t`t: " $VDITemplate.InheritDefaultVDIActionSettings.ToString()    
                                        Line 4 "Application session lingering"    
                                        Line 5 "Logoff active session after`t: " $VDITemplateLogoffActiveSessionAfter                                   Line 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"
                                        Line 4 "Actions"    
                                        Line 5 "On session`t`t`t: " $VDITemplateActionsOnSession    
                                        Line 5 "Perform action`t`t`t: " $VDITemplateActionsPerformAction    
                                        Line 5 "After`t`t`t`t: " $VDITemplateActionsAfter    
                                        Line 0 ""                                   Line 0 ""
                                }                           }
                                If($HTML)                           If($HTML)
                                {                           {
                                    WriteHTMLLine 0 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"
                                        $rowdata = @()    
                                        $columnHeaders = @("Inherit default settings",($Script:htmlsb),$VDITemplate.InheritDefaultVDIActionSettings.ToString(),$htmlwhite)    
                                        $rowdata += @(,("Application session lingering",($Script:htmlsb),"",$htmlwhite))    
                                        $rowdata += @(,( "     Logoff active session after",($Script:htmlsb),$VDITemplateLogoffActiveSessionAfter,$htmlwhite))    
                                        $rowdata += @(,( "Actions",($Script:htmlsb),"",$htmlwhite))    
                                        $rowdata += @(,( "     On session",($Script:htmlsb),$VDITemplateActionsOnSession,$htmlwhite))    
                                        $rowdata += @(,( "     Perform action",($Script:htmlsb),$VDITemplateActionsPerformAction,$htmlwhite))    
                                        $rowdata += @(,( "     After",($Script:htmlsb),$VDITemplateActionsAfter,$htmlwhite))    
     
                                        $msg = "Settings"    
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                                }                           }
     
                                #Security    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 4 0 "Security"    
                                }                   }
                                If($Text)    
                                {                  
                                        Line 3 "Security"                   #Desktops
                    #can't find this
                                }           }
                                If($HTML)    
                                {          
                                        #Nothing           #Remote PCs are not in PoSH
                                }          
            $GWs = Get-RASGW -Siteid $Site.Id -EA 0 4> $Null
                                          
                                If($VDITemplate.InheritDefaultVDISecuritySettings)           If(!$?)
                                {           {
                                        #do we inherit site defaults?                   Write-Warning "
                                        #yes we do, get the default settings for the Site    
                                        #use the Site default settings    
                    `n
                                        $VDIDefaults = Get-RASVDIDefaultSettings -SiteId $Site.Id -EA 0 4>$Null                   Unable to retrieve Gateways for Site $($Site.Name)`
                                            
                                        If($? -and $Null -ne $VDIDefaults)    
                                        {                   "
                                                $VDITemplateGrantPermissions  = $VDIDefaults.IsUsersGrantedRDPermissions.ToString()                   If($MSWord -or $PDF)
                                                If($VDIDefaults.GroupType -eq "Administrators")    
                                                {                   {
                                                        $VDITemplateSecurityGroup = "Administrators"                           WriteWordLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)"
                                                }                   }
                                                Else                   If($Text)
                                                {                   {
                                                        $VDITemplateSecurityGroup = "Remote Desktop Users group"                           Line 0 "Unable to retrieve Gateways for Site $($Site.Name)"
                                                }                   }
                                        }                   If($HTML)
                                        Else    
                                        {                   {
                                                #unable to retrieve default, use built-in default values                           WriteHTMLLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)"
                                                $VDITemplateGrantPermissions = "False"    
                                                $VDITemplateSecurityGroup    = ""    
                                        }                   }
                                }           }
                                Else           ElseIf($? -and $Null -eq $GWs)
                                {           {
                                        #No, we don't use the VDI Template settings                   Write-Host "
                                        $VDITemplateGrantPermissions  = $VDITemplate.IsUsersGrantedRDPermissions.ToString()    
                                        If($VDITemplate.GroupType -eq "Administrators")                   No Gateways retrieved for Site $($Site.Name).`
                                        {                   " -ForegroundColor White
                                                $VDITemplateSecurityGroup = "Administrators"    
                                        }    
                                        Else    
                                        {    
                                                $VDITemplateSecurityGroup = "Remote Desktop Users group"    
                                        }    
                                }    
                                    
                                If($MSWord -or $PDF)                   If($MSWord -or $PDF)
                                {                   {
                                        $ScriptInformation = New-Object System.Collections.ArrayList                           WriteWordLine 0 0 "No Gateways retrieved for Site $($Site.Name)"
                                        $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefaultVDISecuritySettings.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Grant users Remote Desktop connection permissions"; Value = $VDITemplateGrantPermissions; }) > $Null    
                                        If($VDITemplateGrantPermissions -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Local security group"; Value = $VDITemplateSecurityGroup; }) > $Null    
                                        }                   }
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)                   If($Text)
                                {                   {
                                        Line 4 "Inherit default settings`t`t`t : " $VDITemplate.InheritDefaultVDISecuritySettings.ToString()                           Line 0 "No Gateways retrieved for Site $($Site.Name)"
                                        Line 4 "Grant users Remote Desktop connection permissions: " $VDITemplateGrantPermissions    
                                        If($VDITemplateGrantPermissions -eq "True")    
                                        {    
                                                Line 5 "Local security group`t`t`t : " $VDITemplateSecurityGroup    
                                        }                   }
                                        Line 0 ""    
                                }    
                                If($HTML)                   If($HTML)
                                {                   {
                            WriteHTMLLine 0 0 "No Gateways retrieved for Site $($Site.Name)"
                                        $rowdata = @()    
                                        $columnHeaders = @("Inherit default settings",($Script:htmlsb),$VDITemplate.InheritDefaultVDISecuritySettings.ToString(),$htmlwhite)    
                                        $rowdata += @(,( "Grant users Remote Desktop connection permissions",($Script:htmlsb),$VDITemplateGrantPermissions,$htmlwhite))    
                                        If($VDITemplateGrantPermissions -eq "True")    
                                        {    
                                                $rowdata += @(,( "Local security group",($Script:htmlsb),$VDITemplateSecurityGroup,$htmlwhite))    
                                        }    
     
                                        $msg = "Security"    
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                        }    
     
 
                 +-  
                #Write-Verbose "$(Get-Date -Format G): `tOutput VDI Desktops"    
                #Desktops    
                ###ADD LATER    
                    
                #Write-Verbose "$(Get-Date -Format G): `tOutput VDI Scheduler"    
                #Scheduler    
                #not in PoSH    
 
  <>         Else
        #Remote PCs are not in PoSH    
                  {
        #Providers    
        Write-Verbose "$(Get-Date -Format G): Output Providers"    
        If($MSWord -or $PDF)                   If($MSWord -or $PDF)
        {                   {
                WriteWordLine 2 0 "Providers"                           WriteWordLine 2 0 "Gateways"
        }                   }
        If($Text)                   If($Text)
        {                   {
                Line 1 "Providers"                           Line 1 "Gateways"
        }                   }
        If($HTML)                   If($HTML)
        {                   {
                WriteHTMLLine 2 0 "Providers"                           WriteHTMLLine 2 0 "Gateways"
        }                   }
 
  <>                 Write-Verbose "$(Get-Date -Format G): `t`tOutput Gateways"
                    ForEach($GW in $GWs)
                    {
        $Providers = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null                           $GWStatus = Get-RASGWStatus -Id $GW.Id -EA 0 4>$Null
                                  
        If(!$?)                           If(!$?)
        {                           {
                Write-Warning "                                   Write-Warning "
                `n                                   `n
                Unable to retrieve Providers for Site $($Site.Name)`                                   Unable to retrieve Gateway Status for Gateway $($GW.Id)`
                "                                   "
                If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                {                                   {
                        WriteWordLine 0 0 "Unable to retrieve Providers for Site $($Site.Name)"                                           WriteWordLine 0 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)"
                }                                   }
                If($Text)                                   If($Text)
                {                                   {
                        Line 0 "Unable to retrieve Providers for Site $($Site.Name)"                                           Line 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)"
                }                                   }
                If($HTML)                                   If($HTML)
                {                                   {
                        WriteHTMLLine 0 0 "Unable to retrieve Providers for Site $($Site.Name)"                                           WriteHTMLLine 0 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)"
                }                                   }
                                    #unable to retrieve
                                    $GWEnableHSTS            = "Unable to retrieve Gateway Status"
                                    $GWEnableSSL             = "Unable to retrieve Gateway Status"
                                    $GWEnableSSLOnPort       = "Unable to retrieve Gateway Status"
                                    $GWAcceptedSSLVersions   = "Unable to retrieve Gateway Status"
                                    $GWCipherStrength        = "Unable to retrieve Gateway Status"
                                    $GWCipher                = "Unable to retrieve Gateway Status"
                                    $GWCertificates          = "Unable to retrieve Gateway Status"
                                    $GWHSTSMaxage            = "Unable to retrieve Gateway Status"
                                    $GWHSTSIncludeSubdomains = "Unable to retrieve Gateway Status"
                                    $GWHSTSPreload           = "Unable to retrieve Gateway Status"
        }                           }
        ElseIf($? -and $Null -eq $Providers)                           ElseIf($? -and $Null -eq $GWStatus)
        {                           {
                Write-Host "                                   Write-Host "
        No Providers retrieved for Site $($Site.Name).`                                   No Gateway Status retrieved for Gateway $($GW.Id)`
                " -ForegroundColor White                                   " -ForegroundColor White
                If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                {                                   {
                        WriteWordLine 0 0 "No Providers retrieved for Site $($Site.Name)"                                           WriteWordLine 0 0 "No Gateway Status found for Gateway $($GW.Id)"
                }                                   }
                If($Text)                                   If($Text)
                {                                   {
                        Line 0 "No Providers retrieved for Site $($Site.Name)"                                           Line 0 "No Gateway Status found for Gateway $($GW.Id)"
                }                                   }
                If($HTML)                                   If($HTML)
                {                                   {
                        WriteHTMLLine 0 0 "No Providers retrieved for Site $($Site.Name)"                                           WriteHTMLLine 0 0 "No Gateway Status found for Gateway $($GW.Id)"
                }                                   }
                                    #set all to blank
                                    $GWEnableHSTS            = ""
                                    $GWEnableSSL             = ""
                                    $GWEnableSSLOnPort       = ""
                                    $GWAcceptedSSLVersions   = ""
                                    $GWCipherStrength        = ""
                                    $GWCipher                = ""
                                    $GWCertificates          = ""
                                    $GWHSTSMaxage            = ""
                                    $GWHSTSIncludeSubdomains = ""
                                    $GWHSTSPreload           = ""
        }                           }
        Else                           Else
        {                           {
                ForEach($Provider in $Providers)                                   If($GW.InheritDefaultSslTlsSettings)
                {                                   {
                                            #do we inherit site defaults?
                                            #yes we do, get the default settings for the Site
                                            #use the Site default settings
     
                        $ProviderStatus = Get-RASProviderStatus -Id $Provider.Id -EA 0 4>$Null                                           $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                                                  
                        If(!$?)                                           If($? -and $Null -ne $GWDefaults)
                        {                                           {
                                Write-Warning "                                                   If($GWDefaults.EnableHSTS)
                                `n    
                                Unable to retrieve Provider Status for Provider $($Provider.Id)`    
                                "    
                                If($MSWord -or $PDF)    
                                {                                                   {
                                        WriteWordLine 0 0 "Unable to retrieve Provider Status for Provider $($Provider.Id)"                                                           $GWEnableHSTS            = $GWDefaults.EnableHSTS.ToString()
                                                            $GWHSTSMaxage            = $GWDefaults.HSTSMaxAge.ToString()
                                                            $GWHSTSIncludeSubdomains = $GWDefaults.HSTSIncludeSubdomains.ToString()
                                                            $GWHSTSPreload           = $GWDefaults.HSTSPreload.ToString()
                                }                                                   }
                                If($Text)                                                   Else
                                {                                                   {
                                        Line 0 "Unable to retrieve Provider Status for Provider $($Provider.Id)"                                                           $GWEnableHSTS = $GWDefaults.EnableHSTS.ToString()
                                }                                                   }
                                If($HTML)                                                   $GWEnableSSL       = $GWDefaults.EnableSSL.ToString()
                                                    $GWEnableSSLOnPort = $GWDefaults.SSLPort.ToString()
                                                    
                                                    Switch ($GWDefaults.MinSSLVersion)
                                {                                                   {
                                        WriteHTMLLine 0 0 "Unable to retrieve Provider Status for Provider $($Provider.Id)"                                                           "SSLv2"         {$GWAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}
                                                            "SSLv3"         {$GWAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}
                                                            "TLSv1"         {$GWAcceptedSSLVersions = "TLS v1 - TLS v1.2"; Break}
                                                            "TLSv1_1"       {$GWAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}
                                                            "TLSv1_2"       {$GWAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}
                                                            Default         {$GWAcceptedSSLVersions = "Unable to determine Minimum SSL Version: $($GWDefaults.MinSSLVersion)"; Break}
                                }                                                   }
                                                    
                                                    $GWCipherStrength = $GWDefaults.CipherStrength.ToString()
                                                    $GWCipher         = $GWDefaults.Cipher
                                                    
                                                    If($GWDefaults.CertificateId -eq 0)
                                                    {
                                                            $GWCertificates = "All matching usage"
                        }                                                   }
                        ElseIf($? -and $Null -eq $ProviderStatus)                                                   Else
                        {                                                   {
                                Write-Host "                                                           $Results = Get-RASCertificate -Id $GWDefaults.CertificateId -EA 0 4>$Null
                                No Provider Status retrieved for Provider $($Provider.Id)`                                                          
                                " -ForegroundColor White                                                           If($? -and $Null -ne $Results)
                                If($MSWord -or $PDF)    
                                {                                                           {
                                        WriteWordLine 0 0 "No Provider Status retrieved for Provider $($Provider.Id)"                                                                   $GWCertificates = $Results.Name
                                }                                                           }
                                If($Text)                                                           Else
                                {                                                           {
                                        Line 0 "No Provider Status retrieved for Provider $($Provider.Id)"                                                                   $GWCertificates = "Unable to determin Gateway Certificate: $($GWDefaults.CertificateId)"
                                }                                                           }
                                If($HTML)                                                   }
                                            }
                                            Else
                                {                                           {
                                        WriteHTMLLine 0 0 "No Provider Status retrieved for Provider $($Provider.Id)"                                                   #unable to retrieve default, use built-in default values
                                                    $GWEnableHSTS          = "False"
                                                    $GWEnableSSL           = "True"
                                                    $GWEnableSSLOnPort     = "443"
                                                    $GWAcceptedSSLVersions = "TLS v1 - TLS v1.2"
                                                    $GWCipherStrength      = "High"
                                                    $GWCipher              = "EECDH:!SSLv2:!SSLv3:!aNULL:!RC4:!ADH:!eNULL:!LOW:!MEDIUM:!EXP:+HIGH"
                                                    $GWCertificates        = "All matching usage"
                                }                                           }
                        }                                   }
                        Else                                   Else
                        {                                   {
                                $FullProviderStatus = GetRASStatus $ProviderStatus.AgentState                                           #we don't inherit settings
                                            #get the settings configured for this GW
                                If($MSWord -or $PDF)                                           If($GW.EnableHSTS)
                                {                                           {
                                        WriteWordLine 3 0 "Provider $($Provider.Name)"                                                   $GWEnableHSTS            = $GW.EnableHSTS.ToString()
                                                    $GWHSTSMaxage            = $GW.HSTSMaxAge.ToString()
                                                    $GWHSTSIncludeSubdomains = $GW.HSTSIncludeSubdomains.ToString()
                                                    $GWHSTSPreload           = $GW.HSTSPreload.ToString()
                                }                                           }
                                If($Text)                                           Else
                                {                                           {
                                        Line 2 "Provider $($Provider.Name)"                                                   $GWEnableHSTS = $GW.EnableHSTS.ToString()
                                }                                           }
                                If($HTML)                                           $GWEnableSSL       = $GW.EnableSSL.ToString()
                                            $GWEnableSSLOnPort = $GW.SSLPort.ToString()
                                            
                                            Switch ($GW.MinSSLVersion)
                                {                                           {
                                        WriteHTMLLine 3 0 "Provider $($Provider.Name)"                                                   "SSLv2"         {$GWAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}
                                                    "SSLv3"         {$GWAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}
                                                    "TLSv1"         {$GWAcceptedSSLVersions = "TLS v1 - TLS v1.2"; Break}
                                                    "TLSv1_1"       {$GWAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}
                                                    "TLSv1_2"       {$GWAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}
                                                    Default         {$GWAcceptedSSLVersions = "Unable to determine Minimum SSL Version: $($GW.MinSSLVersion)"; Break}
                                }                                           }
                                            
                                $VDIType = GetVDIType $Provider.Type                                           $GWCipherStrength = $GW.CipherStrength.ToString()
                                            $GWCipher         = $GW.Cipher
                                                                          
                                Switch($ProviderStatus.HighAvailabilityState)                                           If($GW.CertificateId -eq 0)
                                {                                           {
                                        "Off"           {$HAMode = "Off"; Break}                                                   $GWCertificates = "All matching usage"
                                        "On_Pref"       {$HAMode = "On (Preferred)"; Break}    
                                        "On_Auto"       {$HAMode = "On (Auto)"; Break}    
                                        Default         {$HAMode = "Unable to determine High Availability mode: $($ProviderStatus.HighAvailabilityState)"; Break}    
                                }                                           }
                                                                          Else
                                If($MSWord -or $PDF)    
                                {                                           {
                                        $ScriptInformation = New-Object System.Collections.ArrayList                                                   $Results = Get-RASCertificate -Id $GW.CertificateId -EA 0 4>$Null
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $Provider.Name; }) > $Null                                                  
                                        $ScriptInformation.Add(@{Data = "Enabled"; Value = $Provider.Enabled.ToString(); }) > $Null                                                   If($? -and $Null -ne $Results)
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $FullProviderStatus; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $Provider.Description; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Provider Agent"; Value = $Provider.VDIAgent; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "High availability"; Value = $HAMode; }) > $Null    
                                        If($VDIType -like "*azure*")    
                                        {                                                   {
                                                $ScriptInformation.Add(@{Data = "Tenant ID"; Value = $Provider.VDIAzureCloudInfo.TenantID; }) > $Null                                                           #double replace to remove the < and > from the cert name so it doesn't mess up HTML output
                                                $ScriptInformation.Add(@{Data = "Subscription ID"; Value = $Provider.VDIAzureCloudInfo.SubscriptionID; }) > $Null                                                           $GWCertificates = $Results.Name.Replace("<","").Replace(">","")
                                        }                                                   }
                                        Else                                                   Else
                                        {                                                   {
                                                $ScriptInformation.Add(@{Data = "Tenant ID"; Value = ""; }) > $Null                                                           $GWCertificates = "Unable to determine Gateway Certificate: $($GW.CertificateId)"
                                                $ScriptInformation.Add(@{Data = "Subscription ID"; Value = ""; }) > $Null                                                   }
 
  <>                                 }
                                    
                                    $GWStatusAgentState = GetRASStatus $GWStatus.AgentState
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 3 0 "Gateways $($GW.Server)"
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Server"; Value = $GW.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Mode"; Value = $GW.GWMode; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Status"; Value = $GWStatusAgentState; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Application ID"; Value = $Provider.VDIUsername; }) > $Null                                           $ScriptInformation.Add(@{Data = "Description"; Value = $GW.Description; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Certificate"; Value = $GWCertificates; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Log level"; Value = $ProviderStatus.LogLevel; }) > $Null                                           $ScriptInformation.Add(@{Data = "Log level"; Value = $GWStatus.LogLevel; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Provider.AdminLastMod; }) > $Null                                           $ScriptInformation.Add(@{Data = "Last modification by"; Value = $GW.AdminLastMod; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $Provider.TimeLastMod.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Modified on"; Value = $GW.TimeLastMod.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $Provider.AdminCreate; }) > $Null                                           $ScriptInformation.Add(@{Data = "Created by"; Value = $GW.AdminCreate; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $Provider.TimeCreate.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Created on"; Value = $GW.TimeCreate.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "ID"; Value = $Provider.Id.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "ID"; Value = $GW.Id.ToString(); }) > $Null
 
                                        Line 3 "Name`t`t`t: " $Provider.Name <>  
                                        Line 3 "Enabled`t`t`t: " $Provider.Enabled.ToString()    
                                        Line 3 "Status`t`t`t: " $FullProviderStatus    
                                        Line 3 "Type`t`t`t: " $VDIType    
                                        Line 3 "Description`t`t: " $Provider.Description    
                                        Line 3 "Provider Agent`t`t: " $Provider.VDIAgent    
                                        Line 3 "High availability`t: " $HAMode    
                                        If($VDIType -like "*azure*")    
                                        {    
                                                Line 3 "Tenant ID`t`t: " $Provider.VDIAzureCloudInfo.TenantID    
                                                Line 3 "Subscription ID`t`t: " $Provider.VDIAzureCloudInfo.SubscriptionID    
                                        }    
                                        Else    
                                        {    
                                                Line 3 "Tenant ID`t`t: "    
                                                Line 3 "Subscription ID`t`t: "    
                                        }    
                                        Line 3 "Application ID`t`t: " $Provider.VDIUsername    
                                        Line 3 "Log level`t`t: " $ProviderStatus.LogLevel    
                                        Line 3 "Last modification by`t: " $Provider.AdminLastMod    
                                        Line 3 "Modified on`t`t: " $Provider.TimeLastMod.ToString()    
                                        Line 3 "Created by`t`t: " $Provider.AdminCreate    
                                        Line 3 "Created on`t`t: " $Provider.TimeCreate.ToString()    
                                        Line 3 "ID`t`t`t: " $Provider.Id.ToString()    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Name",($Script:htmlsb),$Provider.Name,$htmlwhite)    
                                        $rowdata += @(,("Enabled",($Script:htmlsb),$Provider.Enabled.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Status",($Script:htmlsb),$FullProviderStatus,$htmlwhite))    
                                        $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))    
                                        $rowdata += @(,("Description",($Script:htmlsb),$Provider.Description,$htmlwhite))    
                                        $rowdata += @(,("Provider Agent",($Script:htmlsb),$Provider.VDIAgent,$htmlwhite))    
                                        If($VDIType -like "*azure*")    
                                        {    
                                                $rowdata += @(,("Tenant ID",($Script:htmlsb),$Provider.VDIAzureCloudInfo.TenantID,$htmlwhite))    
                                                $rowdata += @(,("Subscription ID",($Script:htmlsb),$Provider.VDIAzureCloudInfo.SubscriptionID,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("Tenant ID",($Script:htmlsb),"",$htmlwhite))    
                                                $rowdata += @(,("Subscription ID",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                        $rowdata += @(,("Application ID",($Script:htmlsb),$Provider.VDIUsername,$htmlwhite))    
                                        $rowdata += @(,("Log level",($Script:htmlsb),$ProviderStatus.LogLevel,$htmlwhite))    
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $Provider.AdminLastMod,$htmlwhite))    
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $Provider.TimeLastMod.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Created by",($Script:htmlsb), $Provider.AdminCreate,$htmlwhite))    
                                        $rowdata += @(,("Created on",($Script:htmlsb), $Provider.TimeCreate.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Id",($Script:htmlsb),$Provider.Id.ToString(),$htmlwhite))    
     
                                        $msg = ""    
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                        }    
                            
                        #General    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "General"    
                        }    
                        If($Text)    
                        {    
                                Line 3 "General"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If(validobject $Provider PreferredBrokerId)    
                        {    
                                $HostPA = Get-RASBroker -Id $Provider.PreferredBrokerId -EA 0 4>$Null    
                        }    
                        Else    
                        {    
                                $HostPA = $Null    
                                $DedicatedVDIAgent = $False    
                        }    
                            
                        If($? -and -$Null -ne $HostPA)    
                        {    
                                If(validobject $HostPA Server)    
                                {    
                                        If($Provider.VDIAgent -eq $HostPa.Server)    
                                        {    
                                                $DedicatedVDIAgent = $False    
                                        }    
                                        Else    
                                        {    
                                                $DedicatedVDIAgent = $True    
                                        }    
                                }    
                                Else    
                                {    
                                        $DedicatedVDIAgent = $False    
                                }    
                        }    
                        ElseIf($? -and $Null -eq $HostPA)    
                        {    
                                $DedicatedVDIAgent = $False    
                        }    
                        Else    
                        {    
                                $DedicatedVDIAgent = $False    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Enable provider in site"; Value = $Provider.Enabled.ToString(); }) > $Null    
                                If($VDIType -eq "Azure")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $Provider.Name; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $Provider.Description; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Subscription details"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Authentication URL"; Value = $Provider.VDIAzureCloudInfo.AuthenticationURL; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Management URL"; Value = $Provider.VDIAzureCloudInfo.ManagementURL; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Resource URI"; Value = $Provider.VDIAzureCloudInfo.ResourceURI; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Tenant ID"; Value = $Provider.VDIAzureCloudInfo.TenantID; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Subscription ID"; Value = $Provider.VDIAzureCloudInfo.SubscriptionID; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $Provider.Name; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $Provider.Description; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Host"; Value = $Provider.Server; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Port"; Value = $Provider.VDIPort.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Resource pool"; Value = $Provider.ResourcePool; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "Dedicated Provider Agent"; Value = $DedicatedVDIAgent.ToString(); }) > $Null    
                                If($DedicatedVDIAgent)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Agent address"; Value = $Provider.VDIAgent; }) > $Null    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 4 "Enable provider in site`t`t: " $Provider.Enabled.ToString()    
                                If($VDIType -eq "Azure")    
                                {    
                                        Line 4 "Type`t`t`t`t: " $VDIType    
                                        Line 4 "Name`t`t`t`t: " $Provider.Name    
                                        Line 4 "Description`t`t`t: " $Provider.Description    
                                        Line 4 "Subscription details`t`t: "     
                                        Line 5 "Authentication URL: " $Provider.VDIAzureCloudInfo.AuthenticationURL    
                                        Line 5 "Management URL`t  : " $Provider.VDIAzureCloudInfo.ManagementURL    
                                        Line 5 "Resource URI`t  : " $Provider.VDIAzureCloudInfo.ResourceURI    
                                        Line 4 "Tenant ID`t`t`t: " $Provider.VDIAzureCloudInfo.TenantID    
                                        Line 4 "Subscription ID`t`t`t: " $Provider.VDIAzureCloudInfo.SubscriptionID    
                                }    
                                Else    
                                {    
                                        Line 4 "Name`t`t`t`t: " $Provider.Name    
                                        Line 4 "Description`t`t`t: " $Provider.Description    
                                        Line 4 "Type`t`t`t`t: " $VDIType    
                                        Line 4 "Host`t`t`t`t: " $Provider.Server    
                                        Line 4 "Port`t`t`t`t: " $Provider.VDIPort.ToString()    
                                        Line 4 "Description`t`t`t: " $Provider.Description    
                                        Line 4 "Resource pool`t`t`t: " $Provider.ResourcePool    
                                }    
                                Line 4 "Dedicated Provider Agent`t: " $DedicatedVDIAgent.ToString()    
                                If($DedicatedVDIAgent)    
                                {    
                                        Line 4 "Agent address`t`t`t: " $Provider.VDIAgent    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Enable provider in site",($Script:htmlsb),$Provider.Enabled.ToString(),$htmlwhite)    
                                If($VDIType -eq "Azure")    
                                {    
                                        $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))    
                                        $rowdata += @(,("Name",($Script:htmlsb), $Provider.Name,$htmlwhite))    
                                        $rowdata += @(,("Description",($Script:htmlsb), $Provider.Description,$htmlwhite))    
                                        $rowdata += @(,("Subscription details",($Script:htmlsb), "",$htmlwhite))    
                                        $rowdata += @(,("     Authentication URL",($Script:htmlsb), $Provider.VDIAzureCloudInfo.AuthenticationURL,$htmlwhite))    
                                        $rowdata += @(,("     Management URL",($Script:htmlsb), $Provider.VDIAzureCloudInfo.ManagementURL,$htmlwhite))    
                                        $rowdata += @(,("     Resource URI",($Script:htmlsb), $Provider.VDIAzureCloudInfo.ResourceURI,$htmlwhite))    
                                        $rowdata += @(,("Tenant ID",($Script:htmlsb), $Provider.VDIAzureCloudInfo.TenantID,$htmlwhite))    
                                        $rowdata += @(,("Subscription ID",($Script:htmlsb), $Provider.VDIAzureCloudInfo.SubscriptionID,$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Name",($Script:htmlsb), $Provider.Name,$htmlwhite))    
                                        $rowdata += @(,("Description",($Script:htmlsb), $Provider.Description,$htmlwhite))    
                                        $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))    
                                        $rowdata += @(,("Host",($Script:htmlsb),$Provider.Server,$htmlwhite))    
                                        $rowdata += @(,("Port",($Script:htmlsb),$Provider.VDIPort.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Description",($Script:htmlsb),$Provider.Description,$htmlwhite))    
                                        $rowdata += @(,("Resource pool",($Script:htmlsb),$Provider.ResourcePool,$htmlwhite))    
                                }    
                                $rowdata += @(,("Dedicated Provider Agent",($Script:htmlsb),$DedicatedVDIAgent.ToString(),$htmlwhite))    
                                If($DedicatedVDIAgent)    
                                {    
                                        $rowdata += @(,("Agent address",($Script:htmlsb),$Provider.VDIAgent,$htmlwhite))    
                                }    
     
                                $msg = "General"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
                        #Credentials    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Credentials"    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Credentials"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                If($VDIType -eq "Azure")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Application ID"; Value = $Provider.VDIUsername; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "Username"; Value = $Provider.VDIUsername; }) > $Null    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                If($VDIType -eq "Azure")    
                                {    
                                        Line 4 "Application ID: " $Provider.VDIUsername    
                                }    
                                Else    
                                {    
                                        Line 4 "Username`t`t`t: " $Provider.VDIUsername    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                If($VDIType -eq "Azure")    
                                {    
                                        $columnHeaders = @("Application ID",($Script:htmlsb),$Provider.VDIUsername,$htmlwhite)    
                                }    
                                Else    
                                {    
                                        $columnHeaders = @("Username",($Script:htmlsb),$Provider.VDIUsername,$htmlwhite)    
                                }    
     
                                $msg = "Credentials"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Agent Settings    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Agent settings"    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Agent settings"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If(validObject $Provider DragAndDropMode)    
                        {    
                                Switch ($Provider.DragAndDropMode)    
                                {    
                                        "Bidirectional"         {$VDIDragAndDrop = "Bidirectional";     
                                        $VDIAllowDragAndDrop = "True";    
                                        Break}    
                                        "Disabled"                      {$VDIDragAndDrop = "Disabled";     
                                        $VDIAllowDragAndDrop = "False";    
                                        Break}    
                                        "ClientToServer"        {$VDIDragAndDrop = "Client to server only";     
                                        $VDIAllowDragAndDrop = "True";    
                                        Break}    
                                        "ServerToClient"        {$VDIDragAndDrop = "Server to client only";     
                                        $VDIAllowDragAndDrop = "True";    
                                        Break}    
                                        Default                         {$VDIDragAndDrop = "Unable to determine Drag and drop: $($Provider.DragAndDropMode)";     
                                        $VDIAllowDragAndDrop = "False";    
                                        Break}    
                                }    
                        }    
                        Else    
                        {    
                                $VDIDragAndDrop = ""    
                                $VDIAllowDragAndDrop = ""    
                        }    
     
                        If(validobject $Provider AllowURLAndMailRedirection)    
                        {    
                                Switch($Provider.AllowURLAndMailRedirection)    
                                {    
                                        "Enabled"                                               {$VDIAllowClientURLMailRedirection = "Enabled";     
                                                                                                         $ReplaceRegisteredApplication = "False";    
                                                                                                         Break}    
                                        "Disabled"                                              {$VDIAllowClientURLMailRedirection = "Disabled";     
                                                                                                         $ReplaceRegisteredApplication = "False";    
                                                                                                         Break}    
                                        "EnabledWithAppRegistration"    {$VDIAllowClientURLMailRedirection = "Enabled";    
                                                                                                         $ReplaceRegisteredApplication = "True";    
                                                                                                         Break}    
                                        Default                                                 {$VDIAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($Provider.AllowURLAndMailRedirection)";     
                                                                                                         $ReplaceRegisteredApplication = "False";    
                                                                                                         Break}    
                                }    
                        }    
                        Else    
                        {    
                                $VDIAllowClientURLMailRedirection = ""    
                                $ReplaceRegisteredApplication = "";    
                        }    
                            
                        If(validobject $Provider FileTransferMode)    
                        {    
                                Switch ($Provider.FileTransferMode)    
                                {    
                                        "Bidirectional"         {$ProviderFileTransferMode = "Bidirectional"; Break}    
                                        "Disabled"                      {$ProviderFileTransferMode = "Disabled"; Break}    
                                        "ClientToServer"        {$ProviderFileTransferMode = "Client to server only"; Break}    
                                        "ServerToClient"        {$ProviderFileTransferMode = "Server to client only"; Break}    
                                        Default                         {$ProviderFileTransferMode = "Unable to determine File Transfer mode: $($Provider.FileTransferMode)"; Break}    
                                }    
                        }    
                        Else    
                        {    
                                $ProviderFileTransferMode = ""    
                        }    
     
                        If(validobject $Provider FileTransferLocation)    
                        {    
                                If($Provider.FileTransferLocation -eq "")    
                                {    
                                        $ProviderFileTransferLocation = "Default download location"    
                                }    
                                Else    
                                {    
                                        $ProviderFileTransferLocation = $ProviderHost.FileTransferLocation    
                                }    
                        }    
                        Else    
                        {    
                                $ProviderFileTransferLocation = ""    
                        }    
     
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $Provider.VDIAgent; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Allow Client URL/Mail Redirection"; Value = $VDIAllowClientURLMailRedirection; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Replace registered application"; Value = $ReplaceRegisteredApplication; }) > $Null    
                                If(validobject $Provider SupportShellURLNamespaceObjects)    
                                {    
                                        $ScriptInformation.Add(@{Data = "     Support Windows Shell URL namespace objects"; Value = $Provider.SupportShellURLNamespaceObjects.ToString(); }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "Enable Drag and drop"; Value = $VDIAllowDragAndDrop; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Direction"; Value = $VDIDragAndDrop; }) > $Null    
                                If(validobject $Provider AllowFileTransfer)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Allow file transfer command (Web (HTML5) and Chrome clients)"; Value = $Provider.AllowFileTransfer.ToString(); }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "     Configure File Transfer"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Direction"; Value = $ProviderFileTransferMode; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Location"; Value = $ProviderFileTransferLocation; }) > $Null    
                                If(validobject $Provider FileTransferLockLocation)    
                                {    
                                        $ScriptInformation.Add(@{Data = "          Do not allow to change location"; Value = $Provider.FileTransferLockLocation.ToString(); }) > $Null    
                                }    
                                If(validobject $Provider EnableDriveRedirectionCache)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Enable drive redirection cache"; Value = $Provider.EnableDriveRedirectionCache.ToString(); }) > $Null    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 4 "Preferred Connection Broker`t`t`t`t`t: " $Provider.VDIAgent    
                                Line 4 "Allow Client URL/Mail Redirection`t`t`t`t: " $VDIAllowClientURLMailRedirection    
                                Line 5 "Replace registered application`t`t`t`t: " $ReplaceRegisteredApplication    
                                If(validobject $Provider SupportShellURLNamespaceObjects)    
                                {    
                                        Line 5 "Support Windows Shell URL namespace objects`t`t: " $Provider.SupportShellURLNamespaceObjects.ToString()    
                                }    
                                Line 4 "Enable Drag and drop`t`t`t`t`t`t: " $VDIAllowDragandDrop    
                                Line 5 "Direction`t`t`t`t`t`t: " $VDIDragAndDrop    
                                If(validobject $Provider AllowFileTransfer)    
                                {    
                                        Line 4 "Allow file transfer command (Web (HTML5) and Chrome clients)`t: " $Provider.AllowFileTransfer.ToString()    
                                }    
                                Line 5 "Configure File Transfer"    
                                Line 6 "Direction`t`t`t: " $ProviderFileTransferMode    
                                Line 6 "Location`t`t`t: " $ProviderFileTransferLocation    
                                If(validobject $Provider FileTransferLockLocation)    
                                {    
                                        Line 6 "Do not allow to change location : " $Provider.FileTransferLockLocation.ToString()    
                                }    
                                If(validobject $Provider EnableDriveRedirectionCache)    
                                {    
                                        Line 4 "Enable drive redirection cache`t`t`t`t`t: " $Provider.EnableDriveRedirectionCache.ToString()    
                                }    
                                    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Preferred Connection Broker",($Script:htmlsb),$Provider.VDIAgent,$htmlwhite)    
                                $rowdata += @(,("Allow Client URL/Mail Redirection",($Script:htmlsb),$VDIAllowClientURLMailRedirection,$htmlwhite))    
                                $rowdata += @(,("     Replace registered application",($Script:htmlsb),$ReplaceRegisteredApplication,$htmlwhite))    
                                If(validobject $Provider SupportShellURLNamespaceObjects)    
                                {    
                                        $rowdata += @(,("     Support Windows Shell URL namespace objects",($Script:htmlsb),$Provider.SupportShellURLNamespaceObjects.ToString(),$htmlwhite))    
                                }    
                                $rowdata += @(,("Enable Drag and drop",($Script:htmlsb),$VDIAllowDragAndDrop,$htmlwhite))    
                                $rowdata += @(,("     Directon",($Script:htmlsb),$VDIDragAndDrop,$htmlwhite))    
                                If(validobject $Provider AllowFileTransfer)    
                                {    
                                        $rowdata += @(,("Allow file transfer command (Web (HTML5) and Chrome clients)",($Script:htmlsb),$Provider.AllowFileTransfer.ToString(),$htmlwhite))    
                                }    
                                $rowdata += @(,("     Configure File Transfer",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("          Direction",($Script:htmlsb),$ProviderFileTransferMode,$htmlwhite))    
                                $rowdata += @(,("          Location",($Script:htmlsb),$ProviderFileTransferLocation,$htmlwhite))    
                                If(validobject $Provider FileTransferLockLocation)    
                                {    
                                        $rowdata += @(,("          Do not allow to change location",($Script:htmlsb),$Provider.FileTransferLockLocation.ToString(),$htmlwhite))    
                                }    
                                If(validobject $Provider EnableDriveRedirectionCache)    
                                {    
                                        $rowdata += @(,("Enable drive redirection cache",($Script:htmlsb),$Provider.EnableDriveRedirectionCache.ToString(),$htmlwhite))    
                                }    
                                    
     
                                $msg = "Agent settings"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #RDP Printer    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "RDP printer"    
                        }    
                        If($Text)    
                        {    
                                Line 3 "RDP printer"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If(validobject $Provider PrinterNameFormat)    
                        {    
                                Switch ($Provider.PrinterNameFormat)    
                                {    
                                        "PrnFormat_PRN_CMP_SES" {$ProviderPrinterNameFormat = "Printername (from Computername) in Session no."; Break}    
                                        "PrnFormat_SES_CMP_PRN" {$ProviderPrinterNameFormat = "Session no. (Computername from) Printername"; Break}    
                                        "PrnFormat_PRN_REDSES"  {$ProviderPrinterNameFormat = "Printername (redirected Session no.)"; Break}    
                                        Default                                 {$ProviderPrinterNameFormat = "Unable to determine RDP Printer Name Format: $($Provider.PrinterNameFormat)"; Break}    
                                }    
                        }    
                        Else    
                        {    
                                $ProviderPrinterNameFormat = ""    
                        }    
                            
                        If(validobject $Provider RemoveSessionNumberFromPrinterName)    
                        {    
                                $ProviderRemoveSessionNumberFromPrinter = $Provider.RemoveSessionNumberFromPrinterName.ToString()    
                        }    
                        Else    
                        {    
                                $ProviderRemoveSessionNumberFromPrinter = ""    
                        }    
     
                        If(validobject $Provider RemoveClientNameFromPrinterName)    
                        {    
                                $ProviderRemoveClientNameFromPrinter = $Provider.RemoveClientNameFromPrinterName.ToString()    
                        }    
                        Else    
                        {    
                                $ProviderRemoveClientNameFromPrinter = ""    
                        }    
     
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "RDP Printer Name Format"; Value = $ProviderPrinterNameFormat; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Remove session number from printer name"; Value = $ProviderRemoveSessionNumberFromPrinter; }) > $Null    
                                If($Provider.RemoveSessionNumberFromPrinterName)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Remove client name from printer name"; Value = $ProviderRemoveClientNameFromPrinter; }) > $Null    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 4 "RDP Printer Name Format`t`t`t`t: " $ProviderPrinterNameFormat    
                                Line 4 "Remove session number from printer name`t`t: " $ProviderRemoveSessionNumberFromPrinter    
                                If($Provider.RemoveSessionNumberFromPrinterName)    
                                {    
                                        Line 4 "Remove client name from printer name`t`t`t: " $ProviderRemoveClientNameFromPrinter    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("RDP Printer Name Format",($Script:htmlsb),$ProviderPrinterNameFormat,$htmlwhite)    
                                $rowdata += @(,("Remove session number from printer name",($Script:htmlsb),$ProviderRemoveSessionNumberFromPrinter,$htmlwhite))    
                                If($Provider.RemoveSessionNumberFromPrinterName)    
                                {    
                                        $rowdata += @(,("Remove client name from printer name",($Script:htmlsb),$ProviderRemoveClientNameFromPrinter,$htmlwhite))    
                                }    
     
                                $msg = "RDP printer"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                }    
        }    
            
        #Remote PCs are not in PoSH    
            
        Write-Verbose "$(Get-Date -Format G): Output Secure Gateways"    
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Secure Gateways"    
        }    
        If($Text)    
        {    
                Line 1 "Secure Gateways"                                           Line 2 "Gateways $($GW.Server)"
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Secure Gateways"    
        }    
     
        $SecureGateways = Get-RASGateway -Siteid $Site.Id -EA 0 4> $Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Secure Gateways for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"    
                }    
        }    
        ElseIf($? -and $Null -eq $SecureGateways)    
        {    
                Write-Host "    
        No Secure Gateways retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Secure Gateways retrieved for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "No Secure Gateways retrieved for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Secure Gateways retrieved for Site $($Site.Name)"    
                }    
        }    
        Else    
        {    
                ForEach($SecureGateway in $SecureGateways)    
                {    
                        $SecureGatewayStatus = Get-RASGatewayStatus -Id $SecureGateway.Id -EA 0 4>$Null    
                            
                        If(!$?)    
                        {    
                                Write-Warning "    
                                `n    
                                Unable to retrieve Secure Gateway Status for Gateway $($SecureGateway.Id)`    
                                "    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "Unable to retrieve Secure Gateway Status for Gateway $($SecureGateway.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "Unable to retrieve Secure Gateway Status for Gateway $($SecureGateway.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "Unable to retrieve Secure Gateway Status for Gateway $($SecureGateway.Id)"    
                                }    
                                #unable to retrieve    
                                $SecureGatewayEnableHSTS            = "Unable to retrieve Secure Gateway Status"    
                                $SecureGatewayEnableSSL             = "Unable to retrieve Secure Gateway Status"    
                                $SecureGatewayEnableSSLOnPort       = "Unable to retrieve Secure Gateway Status"    
                                $SecureGatewayAcceptedSSLVersions   = "Unable to retrieve Secure Gateway Status"    
                                $SecureGatewayCipherStrength        = "Unable to retrieve Secure Gateway Status"    
                                $SecureGatewayCipher                = "Unable to retrieve Secure Gateway Status"    
                                $SecureGatewayCertificates          = "Unable to retrieve Secure Gateway Status"    
                                $SecureGatewayHSTSMaxage            = "Unable to retrieve Secure Gateway Status"    
                                $SecureGatewayHSTSIncludeSubdomains = "Unable to retrieve Secure Gateway Status"    
                                $SecureGatewayHSTSPreload           = "Unable to retrieve Secure Gateway Status"    
                        }    
                        ElseIf($? -and $Null -eq $SecureGatewayStatus)    
                        {    
                                Write-Host "    
                                No Secure Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)`    
                                " -ForegroundColor White    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "No Secure Gateway Status found for Secure Gateway $($SecureGateway.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "No Secure Gateway Status found for Secure Gateway $($SecureGateway.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "No Secure Gateway Status found for Secure Gateway $($SecureGateway.Id)"    
                                }    
                                #set all to blank    
                                $SecureGatewayEnableHSTS            = ""    
                                $SecureGatewayEnableSSL             = ""    
                                $SecureGatewayEnableSSLOnPort       = ""    
                                $SecureGatewayAcceptedSSLVersions   = ""    
                                $SecureGatewayCipherStrength        = ""    
                                $SecureGatewayCipher                = ""    
                                $SecureGatewayCertificates          = ""    
                                $SecureGatewayHSTSMaxage            = ""    
                                $SecureGatewayHSTSIncludeSubdomains = ""    
                                $SecureGatewayHSTSPreload           = ""    
                        }    
                        Else    
                        {    
                                If($SecureGateway.InheritDefaultSslTlsSettings)    
                                {    
                                        #do we inherit site defaults?    
                                        #yes we do, get the default settings for the Site    
                                        #use the Site default settings    
     
                                        $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                            
                                        If($? -and $Null -ne $SecureGatewayDefaults)    
                                        {    
                                                If($SecureGatewayDefaults.EnableHSTS)    
                                                {    
                                                        $SecureGatewayEnableHSTS            = $SecureGatewayDefaults.EnableHSTS.ToString()    
                                                        $SecureGatewayHSTSMaxage            = $SecureGatewayDefaults.HSTSMaxAge.ToString()    
                                                        $SecureGatewayHSTSIncludeSubdomains = $SecureGatewayDefaults.HSTSIncludeSubdomains.ToString()    
                                                        $SecureGatewayHSTSPreload           = $SecureGatewayDefaults.HSTSPreload.ToString()    
                                                }    
                                                Else    
                                                {    
                                                        $SecureGatewayEnableHSTS = $SecureGatewayDefaults.EnableHSTS.ToString()    
                                                }    
                                                $SecureGatewayEnableSSL       = $SecureGatewayDefaults.EnableSSL.ToString()    
                                                $SecureGatewayEnableSSLOnPort = $SecureGatewayDefaults.SSLPort.ToString()    
                                                    
                                                Switch ($SecureGatewayDefaults.MinSSLVersion)    
                                                {    
                                                        "SSLv2"         {$SecureGatewayAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}    
                                                        "SSLv3"         {$SecureGatewayAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}    
                                                        "TLSv1"         {$SecureGatewayAcceptedSSLVersions = "TLS v1 - TLS v1.2"; Break}    
                                                        "TLSv1_1"       {$SecureGatewayAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}    
                                                        "TLSv1_2"       {$SecureGatewayAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}    
                                                        Default         {$SecureGatewayAcceptedSSLVersions = "Unable to determine Minimum SSL Version: $($SecureGatewayDefaults.MinSSLVersion)"; Break}    
                                                }    
                                                    
                                                $SecureGatewayCipherStrength = $SecureGatewayDefaults.CipherStrength.ToString()    
                                                $SecureGatewayCipher         = $SecureGatewayDefaults.Cipher    
                                                    
                                                If($SecureGatewayDefaults.CertificateId -eq 0)    
                                                {    
                                                        $SecureGatewayCertificates = "All matching usage"    
                                                }    
                                                Else    
                                                {    
                                                        $Results = Get-RASCertificate -Id $SecureGatewayDefaults.CertificateId -EA 0 4>$Null    
                                                            
                                                        If($? -and $Null -ne $Results)    
                                                        {    
                                                                $SecureGatewayCertificates = $Results.Name    
                                                        }    
                                                        Else    
                                                        {    
                                                                $SecureGatewayCertificates = "Unable to determin Gateway Certificate: $($SecureGatewayDefaults.CertificateId)"    
                                                        }    
                                                }    
                                        }    
                                        Else    
                                        {    
                                                #unable to retrieve default, use built-in default values    
                                                $SecureGatewayEnableHSTS          = "False"    
                                                $SecureGatewayEnableSSL           = "True"    
                                                $SecureGatewayEnableSSLOnPort     = "443"    
                                                $SecureGatewayAcceptedSSLVersions = "TLS v1 - TLS v1.2"    
                                                $SecureGatewayCipherStrength      = "High"    
                                                $SecureGatewayCipher              = "EECDH:!SSLv2:!SSLv3:!aNULL:!RC4:!ADH:!eNULL:!LOW:!MEDIUM:!EXP:+HIGH"    
                                                $SecureGatewayCertificates        = "All matching usage"    
                                        }    
                                }    
                                Else    
                                {    
                                        #we don't inherit settings    
                                        #get the settings configured for this GW    
                                        If($SecureGateway.EnableHSTS)    
                                        {    
                                                $SecureGatewayEnableHSTS            = $SecureGateway.EnableHSTS.ToString()    
                                                $SecureGatewayHSTSMaxage            = $SecureGateway.HSTSMaxAge.ToString()    
                                                $SecureGatewayHSTSIncludeSubdomains = $SecureGateway.HSTSIncludeSubdomains.ToString()    
                                                $SecureGatewayHSTSPreload           = $SecureGateway.HSTSPreload.ToString()    
                                        }    
                                        Else    
                                        {    
                                                $SecureGatewayEnableHSTS = $SecureGateway.EnableHSTS.ToString()    
                                        }    
                                        $SecureGatewayEnableSSL       = $SecureGateway.EnableSSL.ToString()    
                                        $SecureGatewayEnableSSLOnPort = $SecureGateway.SSLPort.ToString()    
                                            
                                        Switch ($SecureGateway.MinSSLVersion)    
                                        {    
                                                "SSLv2"         {$SecureGatewayAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}    
                                                "SSLv3"         {$SecureGatewayAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}    
                                                "TLSv1"         {$SecureGatewayAcceptedSSLVersions = "TLS v1 - TLS v1.2"; Break}    
                                                "TLSv1_1"       {$SecureGatewayAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}    
                                                "TLSv1_2"       {$SecureGatewayAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}    
                                                Default         {$SecureGatewayAcceptedSSLVersions = "Unable to determine Minimum SSL Version: $($SecureGateway.MinSSLVersion)"; Break}    
                                        }    
                                            
                                        $SecureGatewayCipherStrength = $SecureGateway.CipherStrength.ToString()    
                                        $SecureGatewayCipher         = $SecureGateway.Cipher    
                                            
                                        If($SecureGateway.CertificateId -eq 0)    
                                        {    
                                                $SecureGatewayCertificates = "All matching usage"    
                                        }    
                                        Else    
                                        {    
                                                $Results = Get-RASCertificate -Id $SecureGateway.CertificateId -EA 0 4>$Null    
                                                    
                                                If($? -and $Null -ne $Results)    
                                                {    
                                                        #double replace to remove the < and > from the cert name so it doesn't mess up HTML output    
                                                        $SecureGatewayCertificates = $Results.Name.Replace("<","").Replace(">","")          
                                                }    
                                                Else    
                                                {    
                                                        $SecureGatewayCertificates = "Unable to determine Gateway Certificate: $($SecureGateway.CertificateId)"    
                                                }    
                                        }    
                                }    
                                    
                                $SecureGatewayStatusAgentState = GetRASStatus $SecureGatewayStatus.AgentState    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 3 0 "Secure Gateway $($SecureGateway.Server)"    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Server"; Value = $SecureGateway.Server; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Mode"; Value = $SecureGateway.Mode; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $SecureGatewayStatusAgentState; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $SecureGateway.Description; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Certificate"; Value = $SecureGatewayCertificates; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Log level"; Value = $SecureGatewayStatus.LogLevel; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $SecureGateway.AdminLastMod; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $SecureGateway.TimeLastMod.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $SecureGateway.AdminCreate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $SecureGateway.TimeCreate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "ID"; Value = $SecureGateway.Id.ToString(); }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Secure Gateway $($SecureGateway.Server)"    
                                        Line 3 "Server`t`t`t: " $SecureGateway.Server                                           Line 3 "Server`t`t`t: " $GW.Server
                                        Line 3 "Mode`t`t`t: " $SecureGateway.Mode                                           Line 3 "Mode`t`t`t: " $GW.GWMode
                                        Line 3 "Status`t`t`t: " $SecureGatewayStatusAgentState                                           Line 3 "Status`t`t`t: " $GWStatusAgentState
                                        Line 3 "Description`t`t: " $SecureGateway.Description                                           Line 3 "Description`t`t: " $GW.Description
                                        Line 3 "Certificate`t`t: " $SecureGatewayCertificates                                           Line 3 "Certificate`t`t: " $GWCertificates
                                        Line 3 "Log level`t`t: " $SecureGatewayStatus.LogLevel                                           Line 3 "Log level`t`t: " $GWStatus.LogLevel
                                        Line 3 "Last modification by`t: " $SecureGateway.AdminLastMod                                           Line 3 "Last modification by`t: " $GW.AdminLastMod
                                        Line 3 "Modified on`t`t: " $SecureGateway.TimeLastMod.ToString()                                           Line 3 "Modified on`t`t: " $GW.TimeLastMod.ToString()
                                        Line 3 "Created by`t`t: " $SecureGateway.AdminCreate.ToString()                                           Line 3 "Created by`t`t: " $GW.AdminCreate
                                        Line 3 "Created on`t`t: " $SecureGateway.TimeCreate.ToString()                                           Line 3 "Created on`t`t: " $GW.TimeCreate.ToString()
                                        Line 3 "ID`t`t`t: " $SecureGateway.Id.ToString()                                           Line 3 "ID`t`t`t: " $GW.Id.ToString()
 
                                        WriteHTMLLine 3 0 "Secure Gateway $($SecureGateway.Server)" <>                                         WriteHTMLLine 3 0 "Gateways $($GW.Server)"
 
                                        $columnHeaders = @("Server",($Script:htmlsb),$SecureGateway.Server,$htmlwhite) <>                                         $columnHeaders = @("Server",($Script:htmlsb),$GW.Server,$htmlwhite)
                                        $rowdata += @(,("Mode",($Script:htmlsb),$SecureGateway.Mode.ToString(),$htmlwhite))                                           $rowdata += @(,("Mode",($Script:htmlsb),$GW.GWMode.ToString(),$htmlwhite))
                                        $rowdata += @(,("Status",($Script:htmlsb),$SecureGatewayStatusAgentState.ToString(),$htmlwhite))                                           $rowdata += @(,("Status",($Script:htmlsb),$GWStatusAgentState.ToString(),$htmlwhite))
                                        $rowdata += @(,("Description",($Script:htmlsb),$SecureGateway.Description,$htmlwhite))                                           $rowdata += @(,("Description",($Script:htmlsb),$GW.Description,$htmlwhite))
                                        $rowdata += @(,("Certificate",($Script:htmlsb),$SecureGatewayCertificates,$htmlwhite))                                           $rowdata += @(,("Certificate",($Script:htmlsb),$GWCertificates,$htmlwhite))
                                        $rowdata += @(,("Log level",($Script:htmlsb),$SecureGatewayStatus.LogLevel,$htmlwhite))                                           $rowdata += @(,("Log level",($Script:htmlsb),$GWStatus.LogLevel,$htmlwhite))
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $SecureGateway.AdminLastMod,$htmlwhite))                                           $rowdata += @(,("Last modification by",($Script:htmlsb), $GW.AdminLastMod,$htmlwhite))
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $SecureGateway.TimeLastMod.ToString(),$htmlwhite))                                           $rowdata += @(,("Modified on",($Script:htmlsb), $GW.TimeLastMod.ToString(),$htmlwhite))
                                        $rowdata += @(,("Created by",($Script:htmlsb), $SecureGateway.AdminCreate.ToString(),$htmlwhite))                                           $rowdata += @(,("Created by",($Script:htmlsb), $GW.AdminCreate,$htmlwhite))
                                        $rowdata += @(,("Created on",($Script:htmlsb), $SecureGateway.TimeCreate.ToString(),$htmlwhite))                                           $rowdata += @(,("Created on",($Script:htmlsb), $GW.TimeCreate.ToString(),$htmlwhite))
                                        $rowdata += @(,("ID",($Script:htmlsb),$SecureGateway.Id.ToString(),$htmlwhite))                                           $rowdata += @(,("ID",($Script:htmlsb),$GW.Id.ToString(),$htmlwhite))
 
                        Switch ($SecureGateway.IPVersion) <>                         Switch ($GW.IPVersion)
 
                                Default                 {$IPVersion = "Unable to determine IP version: $($SecureGateway.IPVersion)"; Break} <>                                 Default                 {$IPVersion = "Unable to determine IP version: $($GW.IPVersion)"; Break}
 
                        $SecureGatewayIPs = $SecureGateway.IPs.Split(";") <>                         $GWIPs = $GW.IPs.Split(";")
 
                        If($SecureGateway.BindV4Addresses -eq "") <>                         If($GW.BindV4Addresses -eq "")
 
                                $SecureGatewayBindV4Addresses = "All available addresses" <>                                 $GWBindV4Addresses = "All available addresses"
 
                                $SecureGatewayBindV4Addresses = $SecureGateway.BindV4Addresses <>                                 $GWBindV4Addresses = $GW.BindV4Addresses
 
                        If($SecureGateway.OptimizeConnectionIPv4 -eq "<All>") <>                         If($GW.OptimizeConnectionIPv4 -eq "<All>")
 
                                $SecureGatewayOptimizeV4 = "All available addresses" <>                                 $GWOptimizeV4 = "All available addresses"
 
                        ElseIf($SecureGateway.OptimizeConnectionIPv4 -eq "<None>") <>                         ElseIf($GW.OptimizeConnectionIPv4 -eq "<None>")
 
                                $SecureGatewayOptimizeV4 = "None from the available" <>                                 $GWOptimizeV4 = "None from the available"
 
                                $SecureGatewayOptimizeV4 = $SecureGateway.OptimizeConnectionIPv4 <>                                 $GWOptimizeV4 = $GW.OptimizeConnectionIPv4
 
                        If($SecureGateway.BindV6Addresses -eq "") <>                         If($GW.BindV6Addresses -eq "")
 
                                $SecureGatewayBindV6Addresses = "All available addresses" <>                                 $GWBindV6Addresses = "All available addresses"
 
                                $SecureGatewayBindV6Addresses = $SecureGateway.BindV6Addresses <>                                 $GWBindV6Addresses = $GW.BindV6Addresses
 
                        If($SecureGateway.OptimizeConnectionIPv6 -eq "<All>") <>                         If($GW.OptimizeConnectionIPv6 -eq "<All>")
 
                                $SecureGatewayOptimizeV6 = "All available addresses" <>                                 $GWOptimizeV6 = "All available addresses"
 
                        ElseIf($SecureGateway.OptimizeConnectionIPv6 -eq "<None>") <>                         ElseIf($GW.OptimizeConnectionIPv6 -eq "<None>")
 
                                $SecureGatewayOptimizeV6 = "None from the available" <>                                 $GWOptimizeV6 = "None from the available"
 
                                $SecureGatewayOptimizeV6 = $SecureGateway.OptimizeConnectionIPv6 <>                                 $GWOptimizeV6 = $GW.OptimizeConnectionIPv6
 
                                $ScriptInformation.Add(@{Data = "Enable Secure Gateway in Site"; Value = $SecureGateway.Enabled.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Enable RAS Secure Client Gateway in Site"; Value = $GW.Enabled.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Server"; Value = $SecureGateway.Server; }) > $Null                                   $ScriptInformation.Add(@{Data = "Server"; Value = $GW.Server; }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $SecureGateway.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $GW.Description; }) > $Null
 
                                ForEach($Item in $SecureGatewayIPs) <>                                 ForEach($Item in $GWIPs)
 
                                If($SecureGateway.IPVersion -ne "Version6") <>                                 If($GW.IPVersion -ne "Version6")
 
                                        $ScriptInformation.Add(@{Data = "     Bind to the following IPv4"; Value = $SecureGatewayBindV4Addresses; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "     Bind to the following IPv4"; Value = $GWBindV4Addresses; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Remove system buffers for"; Value = $SecureGatewayOptimizeV4; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Remove system buffers for"; Value = $GWOptimizeV4; }) > $Null
 
                                If($SecureGateway.IPVersion -ne "Version4") <>                                 If($GW.IPVersion -ne "Version4")
 
                                        $ScriptInformation.Add(@{Data = "     Bind to the following IPv6"; Value = $SecureGatewayBindV6Addresses; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "     Bind to the following IPv6"; Value = $GWBindV6Addresses; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Remove system buffers for"; Value = $SecureGatewayOptimizeV6; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Remove system buffers for"; Value = $GWOptimizeV6; }) > $Null
 
                                Line 3 "Enable Secure Gateway in Site: " $SecureGateway.Enabled.ToString() <>                                 Line 3 "Enable RAS Secure Client Gateway in Site: " $GW.Enabled.ToString()
                                Line 3 "Server`t`t`t`t`t: " $SecureGateway.Server                                   Line 3 "Server`t`t`t`t`t: " $GW.Server
                                Line 3 "Description`t`t`t`t: " $SecureGateway.Description                                   Line 3 "Description`t`t`t`t: " $GW.Description
 
                                ForEach($Item in $SecureGatewayIPs) <>                                 ForEach($Item in $GWIPs)
 
                                If($SecureGateway.IPVersion -ne "Version6") <>                                 If($GW.IPVersion -ne "Version6")
 
                                        Line 4 "Bind to the following IPv4`t: " $SecureGatewayBindV4Addresses <>                                         Line 4 "Bind to the following IPv4`t: " $GWBindV4Addresses
                                        Line 4 "Remove system buffers for`t: " $SecureGatewayOptimizeV4                                           Line 4 "Remove system buffers for`t: " $GWOptimizeV4
 
                                If($SecureGateway.IPVersion -ne "Version4") <>                                 If($GW.IPVersion -ne "Version4")
 
                                        Line 4 "Bind to the following IPv6`t: " $SecureGatewayBindV6Addresses <>                                         Line 4 "Bind to the following IPv6`t: " $GWBindV6Addresses
                                        Line 4 "Remove system buffers for`t: " $SecureGatewayOptimizeV6                                           Line 4 "Remove system buffers for`t: " $GWOptimizeV6
 
                                $columnHeaders = @("Enable Secure Gateway in Site",($Script:htmlsb),$SecureGateway.Enabled.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Enable RAS Secure Client Gateway in Site",($Script:htmlsb),$GW.Enabled.ToString(),$htmlwhite)
                                $rowdata += @(,("Server",($Script:htmlsb),$SecureGateway.Server,$htmlwhite))                                   $rowdata += @(,("Server",($Script:htmlsb),$GW.Server,$htmlwhite))
                                $rowdata += @(,("Description",($Script:htmlsb),$SecureGateway.Description,$htmlwhite))                                   $rowdata += @(,("Description",($Script:htmlsb),$GW.Description,$htmlwhite))
 
                                ForEach($Item in $SecureGatewayIPs) <>                                 ForEach($Item in $GWIPs)
 
                                If($SecureGateway.IPVersion -ne "Version6") <>                                 If($GW.IPVersion -ne "Version6")
 
                                        $rowdata += @(,("     Bind to the following IPv4",($Script:htmlsb),$SecureGatewayBindV4Addresses,$htmlwhite)) <>                                         $rowdata += @(,("     Bind to the following IPv4",($Script:htmlsb),$GWBindV4Addresses,$htmlwhite))
                                        $rowdata += @(,("     Remove system buffers for",($Script:htmlsb),$SecureGatewayOptimizeV4,$htmlwhite))                                           $rowdata += @(,("     Remove system buffers for",($Script:htmlsb),$GWOptimizeV4,$htmlwhite))
 
                                If($SecureGateway.IPVersion -ne "Version4") <>                                 If($GW.IPVersion -ne "Version4")
 
                                        $rowdata += @(,("     Bind to the following IPv6",($Script:htmlsb),$SecureGatewayBindV6Addresses,$htmlwhite)) <>                                         $rowdata += @(,("     Bind to the following IPv6",($Script:htmlsb),$GWBindV6Addresses,$htmlwhite))
                                        $rowdata += @(,("     Remove system buffers for",($Script:htmlsb),$SecureGatewayOptimizeV6,$htmlwhite))                                           $rowdata += @(,("     Remove system buffers for",($Script:htmlsb),$GWOptimizeV6,$htmlwhite))
 
                        If($SecureGateway.InheritDefaultModeSettings) <>                         If($GW.InheritDefaultModeSettings)
 
                                $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null <>                                 $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
 
                                If($? -and $Null -ne $SecureGatewayDefaults) <>                                 If($? -and $Null -ne $GWDefaults)
 
                                        $SecureGatewayMode = $SecureGatewayDefaults.Mode.ToString() <>                                         $GWMode = $GWDefaults.GWMode.ToString()
                                        $SecureGatewayForwardRequests = $SecureGatewayDefaults.NormalModeForwarding.ToString()                                           $GWForwardRequests = $GWDefaults.NormalModeForwarding.ToString()
                                        If($SecureGatewayMode -eq "Normal")                                           If($GWMode -eq "Normal")
 
                                                $SecureGatewayServers = $SecureGatewayDefaults.ForwardHttpServers.Split(";") <>                                                 $GWServers = $GWDefaults.ForwardHttpServers.Split(";")
 
                                                $SecureGatewayServers = $SecureGatewayDefaults.ForwardGatewayServers.Split(";") <>                                                 $GWServers = $GWDefaults.ForwardGatewayServers.Split(";")
 
                                        If($SecureGatewayDefaults.PreferredBrokerId -eq 0) <>                                         If($GWDefaults.PreferredPAId -eq 0)
 
                                                $SecureGatewayPreferredConnectionBroker = "Automatic" <>                                                 $GWPreferredPublishingAgent = "Automatically"
 
                                                $SecureGatewayPreferredConnectionBroker = (Get-RASBroker -Id $SecureGatewayDefaults.PreferredBrokerId -EA 0 4>$Null).Server <>                                                 $GWPreferredPublishingAgent = (Get-RASPA -Id $GWDefaults.PreferredPAId -EA 0 4>$Null).Server
 
                                        $SecureGatewayMode = "Normal" <>                                         $GWMode = "Normal"
                                        $SecureGatewayForwardRequests = "False"                                           $GWForwardRequests = "False"
                                        $SecureGatewayServers = @("localhost:81")                                           $GWServers = @("localhost:81")
                                        $SecureGatewayPreferredConnectionBroker = "Automatic"                                           $GWPreferredPublishingAgent = "Automatically"
 
                                $SecureGatewayMode = $SecureGateway.Mode.ToString() <>                                 $GWMode = $GW.GWMode.ToString()
                                $SecureGatewayForwardRequests = $SecureGateway.NormalModeForwarding.ToString()                                   $GWForwardRequests = $GW.NormalModeForwarding.ToString()
                                If($SecureGatewayMode -eq "Normal")                                   If($GWMode -eq "Normal")
 
                                        $SecureGatewayServers = $SecureGateway.ForwardHttpServers.Split(";") <>                                         $GWServers = $GW.ForwardHttpServers.Split(";")
 
                                        $SecureGatewayServers = $SecureGateway.ForwardGatewayServers.Split(";") <>                                         $GWServers = $GW.ForwardGatewayServers.Split(";")
 
                                If($SecureGateway.PreferredBrokerId -eq 0) <>                                 If($GW.PreferredPAId -eq 0)
 
                                        $SecureGatewayPreferredConnectionBroker = "Automatic" <>                                         $GWPreferredPublishingAgent = "Automatically"
 
                                        $SecureGatewayPreferredConnectionBroker = (Get-RASBroker -Id $SecureGateway.PreferredBrokerId -EA 0 4>$Null).Server <>                                         $GWPreferredPublishingAgent = (Get-RASPA -Id $GW.PreferredPAId -EA 0 4>$Null).Server
 
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultModeSettings.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultModeSettings.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Gateway mode"; Value = $SecureGatewayMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "Gateway mode"; Value = $GWMode; }) > $Null
 
                                If($SecureGatewayMode -eq "Normal") <>                                 If($GWMode -eq "Normal")
 
                                        If($SecureGatewayForwardRequests -eq "True") <>                                         If($GWForwardRequests -eq "True")
 
                                                $ScriptInformation.Add(@{Data = "Forward requests to HTTP Server"; Value = $SecureGatewayForwardRequests; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = "Forward requests to HTTP Server"; Value = $GWForwardRequests; }) > $Null
 
                                                ForEach($Item in $SecureGatewayServers) <>                                                 ForEach($Item in $GWServers)
 
                                        $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $SecureGatewayPreferredConnectionBroker; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Preferred Publishing Agent"; Value = $GWPreferredPublishingAgent; }) > $Null
 
                                        $ScriptInformation.Add(@{Data = "Forward requests to next Secure Gateway in chain (cascaded firewall)"; Value = $SecureGatewayForwardRequests; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Forward requests to next RAS Secure Client Gateway in chain (cascaded firewall)"; Value = $GWForwardRequests; }) > $Null
 
                                        $ScriptInformation.Add(@{Data = "Forwarding Secure Gateway(s)"; Value = ""; }) > $Null <>  
                                        If($SecureGatewayForwardRequests -eq "True")                                           If($GWForwardRequests -eq "True")
 
                                                ForEach($Item in $SecureGatewayServers) <>                                                 ForEach($Item in $GWServers)
 
                                Line 3 "Inherit default settings`t`t: " $SecureGateway.InheritDefaultModeSettings.ToString() <>                                 Line 3 "Inherit default settings`t`t: " $GW.InheritDefaultModeSettings.ToString()
                                Line 3 "Gateway mode`t`t`t`t: " $SecureGatewayMode                                   Line 3 "Gateway mode`t`t`t`t: " $GWMode
                                If($SecureGatewayMode -eq "Normal")                                   If($GWMode -eq "Normal")
 
                                        Line 3 "Forward requests to HTTP Server`t`t: " $SecureGatewayForwardRequests <>                                         Line 3 "Forward requests to HTTP Server`t`t: " $GWForwardRequests
 
                                        ForEach($Item in $SecureGatewayServers) <>                                         ForEach($Item in $GWServers)
 
                                        Line 3 "Preferred Connection Broker`t`t: " $SecureGatewayPreferredConnectionBroker <>                                         Line 3 "Preferred Publishing Agent`t`t: " $GWPreferredPublishingAgent
 
                                        Line 3 "Secure Gateway" <>                                         Line 3 "RAS Secure Client Gateway"
                                        Line 3 "in chain (cascaded firewall)`t`t: " $SecureGatewayForwardRequests                                           Line 3 "in chain (cascaded firewall)`t`t: " $GWForwardRequests
 
                                        Line 3 "Forwarding Secure Gateway(s)" <>  
                                        If($SecureGatewayForwardRequests -eq "True")    
                                        {    
                                                $cnt = -1                                           $cnt = -1
                                                ForEach($Item in $SecureGatewayServers)                                           ForEach($Item in $GWServers)
                                                {                                           {
                                                        $cnt++                                                   $cnt++
                                                        $tmparray = $Item.Split(":")                                                   $tmparray = $Item.Split(":")
                                                        $tmpserver = $tmparray[0]                                                   $tmpserver = $tmparray[0]
                                                        $tmpport = $tmparray[1]                                                   $tmpport = $tmparray[1]
                                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                                        {                                                   {
                                                                Line 3 "Server(s)`t`t`t`t: " "Server: $($tmpserver)`tPort: $($tmpport)"                                                           Line 3 "Server(s)`t`t`t`t: " "Server: $($tmpserver)`tPort: $($tmpport)"
                                                        }                                                   }
                                                        Else                                                   Else
                                                        {                                                   {
                                                                Line 8 "  " "Server: $($tmpserver)`tPort: $($tmpport)"                                                           Line 8 "  " "Server: $($tmpserver)`tPort: $($tmpport)"
                                                        }                                                   }
                                                }                                           }
                                        }                                   }
                                }    
 
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultModeSettings.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultModeSettings.ToString(),$htmlwhite)
                                $rowdata += @(,("Gateway mode",($Script:htmlsb),$SecureGatewayMode,$htmlwhite))                                   $rowdata += @(,("Gateway mode",($Script:htmlsb),$GWMode,$htmlwhite))
                                If($SecureGatewayMode -eq "Normal")                                   If($GWMode -eq "Normal")
 
                                        $rowdata += @(,("Forward requests to HTTP Server",($Script:htmlsb),$SecureGatewayForwardRequests,$htmlwhite)) <>                                         $rowdata += @(,("Forward requests to HTTP Server",($Script:htmlsb),$GWForwardRequests,$htmlwhite))
 
                                        ForEach($Item in $SecureGatewayServers) <>                                         ForEach($Item in $GWServers)
 
                                        $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$SecureGatewayPreferredConnectionBroker,$htmlwhite)) <>                                         $rowdata += @(,("Preferred Publishing Agent",($Script:htmlsb),$GWPreferredPublishingAgent,$htmlwhite))
 
                                        $rowdata += @(,("Forward requests to next RAS Secure Client Gateway in chain (cascaded firewall)",($Script:htmlsb),$SecureGatewayForwardRequests,$htmlwhite)) <>                                         $rowdata += @(,("Forward requests to next RAS Secure Client Gateway in chain (cascaded firewall)",($Script:htmlsb),$GWForwardRequests,$htmlwhite))
 
                                        $rowdata += @(,("Forwarding Secure Gateway(s)",($Script:htmlsb),"",$htmlwhite)) <>  
                                        If($SecureGatewayForwardRequests -eq "True")    
                                        {    
                                                $cnt = -1                                           $cnt = -1
                                                ForEach($Item in $SecureGatewayServers)                                           ForEach($Item in $GWServers)
                                                {                                           {
                                                        $cnt++                                                   $cnt++
                                                        $tmparray = $Item.Split(":")                                                   $tmparray = $Item.Split(":")
                                                        $tmpserver = $tmparray[0]                                                   $tmpserver = $tmparray[0]
                                                        $tmpport = $tmparray[1]                                                   $tmpport = $tmparray[1]
                                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                                        {                                                   {
                                                                $rowdata += @(,("Server(s)",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))                                                           $rowdata += @(,("Server(s)",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))
                                                        }                                                   }
                                                        Else                                                   Else
                                                        {                                                   {
                                                                $rowdata += @(,("",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))                                                           $rowdata += @(,("",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))
                                                        }    
 
                        If($SecureGateway.InheritDefaultNetworkSettings) <>                         If($GW.InheritDefaultNetworkSettings)
 
                                $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null <>                                 $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
 
                                If($? -and $Null -ne $SecureGatewayDefaults) <>                                 If($? -and $Null -ne $GWDefaults)
 
                                        $SecureGatewayEnableRASSecureClientGatewayPort             = $SecureGatewayDefaults.EnableGatewayPort.ToString() <>                                         $GWEnableRASSecureClientGatewayPort             = $GWDefaults.EnableGWPort.ToString()
                                        $SecureGatewayRASSecureClientGatewayPort                   = $SecureGatewayDefaults.GatewayPort.ToString()                                           $GWRASSecureClientGatewayPort                   = $GWDefaults.GWPort.ToString()
                                        $SecureGatewayOnlyAllowLetsEncryptVerification             = $SecureGatewayDefaults.OnlyAllowAcmeHttp.ToString()    
                                        $SecureGatewayEnableRDPPort                                = $SecureGatewayDefaults.EnableRDP.ToString()                                           $GWEnableRDPPort                                = $GWDefaults.EnableRDP.ToString()
                                        $SecureGatewayRDPPort                                      = $SecureGatewayDefaults.RDPPort.ToString()                                           $GWRDPPort                                      = $GWDefaults.RDPPort.ToString()
                                        $SecureGatewayEnableBroadcastRASSecureClientGatewayAddress = $SecureGatewayDefaults.Broadcast.ToString()                                           $GWEnableBroadcastRASSecureClientGatewayAddress = $GWDefaults.Broadcast.ToString()
                                        $SecureGatewayEnableRDPUPDDataTunneling                    = $SecureGatewayDefaults.EnableRDPUDP.ToString()                                           $GWEnableRDPUPDDataTunneling                    = $GWDefaults.EnableRDPUDP.ToString()
                                        $SecureGatewayEnableDeviceManagerPort                      = $SecureGatewayDefaults.EnableDeviceManagerPort.ToString()                                           $GWEnableClientManagerPort                      = $GWDefaults.EnableClientManagerPort.ToString()
                                        $SecureGatewayDeviceManagerPort                            = "20009"                                           $GWClientManagerPort                            = "20009"
                                        $SecureGatewayEnableRDPDOSAttackFilter                     = $SecureGatewayDefaults.DOSPro.ToString()                                           $GWEnableRDPDOSAttackFilter                     = $GWDefaults.DOSPro.ToString()
                                        $SecureGatewayCipherPreference                             = $SecureGatewayDefaults.CipherPreference.ToString()                                           $GWCipherPreference                             = $GWDefaults.CipherPreference.ToString()
 
                                        $SecureGatewayEnableRASSecureClientGatewayPort             = "True" <>                                         $GWEnableRASSecureClientGatewayPort             = "True"
                                        $SecureGatewayRASSecureClientGatewayPort                   = "80"                                           $GWRASSecureClientGatewayPort                   = "80"
                                        $SecureGatewayOnlyAllowLetsEncryptVerification             = "False"    
                                        $SecureGatewayEnableRDPPort                                = "False"                                           $GWEnableRDPPort                                = "False"
                                        $SecureGatewayEnableBroadcastRASSecureClientGatewayAddress = "True"                                           $GWEnableBroadcastRASSecureClientGatewayAddress = "True"
                                        $SecureGatewayEnableRDPUPDDataTunneling                    = "True"                                           $GWEnableRDPUPDDataTunneling                    = "True"
                                        $SecureGatewayEnableDeviceManagerPort                      = "True"                                           $GWEnableClientManagerPort                      = "True"
                                        $SecureGatewayDeviceManagerPort                            = "20009"                                           $GWClientManagerPort                            = "20009"
                                        $SecureGatewayEnableRDPDOSAttackFilter                     = "True"                                           $GWEnableRDPDOSAttackFilter                     = "True"
                                        $SecureGatewayCipherPreference                             = "True"                                           $GWCipherPreference                             = "True"
 
                                $SecureGatewayEnableRASSecureClientGatewayPort             = $SecureGateway.EnableGatewayPort.ToString() <>                                 $GWEnableRASSecureClientGatewayPort             = $GW.EnableGWPort.ToString()
                                $SecureGatewayRASSecureClientGatewayPort                   = $SecureGateway.GatewayPort.ToString()                                   $GWRASSecureClientGatewayPort                   = $GW.GWPort.ToString()
                                $SecureGatewayOnlyAllowLetsEncryptVerification             = $SecureGateway.OnlyAllowAcmeHttp.ToString()    
                                $SecureGatewayEnableRDPPort                                = $SecureGateway.EnableRDP.ToString()                                   $GWEnableRDPPort                                = $GW.EnableRDP.ToString()
                                $SecureGatewayRDPPort                                      = $SecureGateway.RDPPort.ToString()                                   $GWRDPPort                                      = $GW.RDPPort.ToString()
                                $SecureGatewayEnableBroadcastRASSecureClientGatewayAddress = $SecureGateway.Broadcast.ToString()                                   $GWEnableBroadcastRASSecureClientGatewayAddress = $GW.Broadcast.ToString()
                                $SecureGatewayEnableRDPUPDDataTunneling                    = $SecureGateway.EnableRDPUDP.ToString()                                   $GWEnableRDPUPDDataTunneling                    = $GW.EnableRDPUDP.ToString()
                                $SecureGatewayEnableDeviceManagerPort                      = $SecureGateway.EnableDeviceManagerPort.ToString()                                   $GWEnableClientManagerPort                      = $GW.EnableClientManagerPort.ToString()
                                $SecureGatewayDeviceManagerPort                            = "20009"                                   $GWClientManagerPort                            = "20009"
                                $SecureGatewayEnableRDPDOSAttackFilter                     = $SecureGateway.DOSPro.ToString()                                   $GWEnableRDPDOSAttackFilter                     = $GW.DOSPro.ToString()
                                $SecureGatewayCipherPreference                             = $SecureGateway.CipherPreference.ToString()                                   $GWCipherPreference                             = $GW.CipherPreference.ToString()
 
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultNetworkSettings.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultNetworkSettings.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable Secure Gateway Port"; Value = $SecureGatewayEnableRASSecureClientGatewayPort; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable RAS Secure Client Gateway Port"; Value = $GWEnableRASSecureClientGatewayPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "Secure Gateway Port"; Value = $SecureGatewayRASSecureClientGatewayPort; }) > $Null                                   $ScriptInformation.Add(@{Data = "RAS Secure Client Gateway Port"; Value = $GWRASSecureClientGatewayPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "Only allow Let's Encrypt verification"; Value = $SecureGatewayOnlyAllowLetsEncryptVerification; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable RDP Port"; Value = $SecureGatewayEnableRDPPort; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable RDP Port"; Value = $GWEnableRDPPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "RDP Port"; Value = $SecureGatewayRDPPort; }) > $Null                                   $ScriptInformation.Add(@{Data = "RDP Port"; Value = $GWRDPPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable Broadcast RAS Secure Client Gateway Address"; Value = $SecureGatewayEnableBroadcastRASSecureClientGatewayAddress; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable Broadcast RAS Secure Client Gateway Address"; Value = $GWEnableBroadcastRASSecureClientGatewayAddress; }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable RDP UDP Data Tunneling"; Value = $SecureGatewayEnableRDPUPDDataTunneling; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable RDP UDP Data Tunneling"; Value = $GWEnableRDPUPDDataTunneling; }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable Device Manager Port"; Value = $SecureGatewayEnableDeviceManagerPort; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable Client Manager Port"; Value = $GWEnableClientManagerPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "Device Manager Port"; Value = $SecureGatewayDeviceManagerPort; }) > $Null                                   $ScriptInformation.Add(@{Data = "Client Manager Port"; Value = $GWClientManagerPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable RDP DOS Attack Filter"; Value = $SecureGatewayEnableRDPDOSAttackFilter; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable RDP DOS Attack Filter"; Value = $GWEnableRDPDOSAttackFilter; }) > $Null
 
                                Line 3 "Inherit default settings`t`t: " $SecureGateway.InheritDefaultNetworkSettings.ToString() <>                                 Line 3 "Inherit default settings`t`t: " $GW.InheritDefaultNetworkSettings.ToString()
                                Line 3 "Enable Secure Gateway Port`t`t: " $SecureGatewayEnableRASSecureClientGatewayPort                                   Line 3 "Enable RAS Secure Client Gateway Port`t: " $GWEnableRASSecureClientGatewayPort
                                Line 3 "Secure Gateway Port`t`t`t: " $SecureGatewayRASSecureClientGatewayPort                                   Line 3 "RAS Secure Client Gateway Port`t`t: " $GWRASSecureClientGatewayPort
                                Line 3 "Only allow Let's Encrypt verification`t: " $SecureGatewayOnlyAllowLetsEncryptVerification    
                                Line 3 "Enable RDP Port`t`t`t`t: " $SecureGatewayEnableRDPPort                                   Line 3 "Enable RDP Port`t`t`t`t: " $GWEnableRDPPort
                                Line 3 "RDP Port`t`t`t`t: " $SecureGatewayRDPPort                                   Line 3 "RDP Port`t`t`t`t: " $GWRDPPort
                                    Line 3 "Enable Broadcast RAS Secure "
                                Line 3 "Enable Broadcast Secure Gateway Address`t: " $SecureGatewayEnableBroadcastRASSecureClientGatewayAddress                                   Line 3 "Client Gateway Address`t`t`t: " $GWEnableBroadcastRASSecureClientGatewayAddress
                                Line 3 "Enable RDP UDP Data Tunneling`t`t: " $SecureGatewayEnableRDPUPDDataTunneling                                   Line 3 "Enable RDP UDP Data Tunneling`t`t: " $GWEnableRDPUPDDataTunneling
                                Line 3 "Enable Device Manager Port`t`t: " $SecureGatewayEnableDeviceManagerPort                                   Line 3 "Enable Client Manager Port`t`t: " $GWEnableClientManagerPort
                                Line 3 "Device Manager Port`t`t`t: " $SecureGatewayDeviceManagerPort                                   Line 3 "Client Manager Port`t`t`t: " $GWClientManagerPort
                                Line 3 "Enable RDP DOS Attack Filter`t`t: " $SecureGatewayEnableRDPDOSAttackFilter                                   Line 3 "Enable RDP DOS Attack Filter`t`t: " $GWEnableRDPDOSAttackFilter
 
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultNetworkSettings.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultNetworkSettings.ToString(),$htmlwhite)
                                $rowdata += @(,("Enable Secure Gateway Port",($Script:htmlsb),$SecureGatewayEnableRASSecureClientGatewayPort,$htmlwhite))                                   $rowdata += @(,("Enable RAS Secure Client Gateway Port",($Script:htmlsb),$GWEnableRASSecureClientGatewayPort,$htmlwhite))
                                $rowdata += @(,("Secure Gateway Port",($Script:htmlsb),$SecureGatewayRASSecureClientGatewayPort,$htmlwhite))                                   $rowdata += @(,("RAS Secure Client Gateway Port",($Script:htmlsb),$GWRASSecureClientGatewayPort,$htmlwhite))
                                $rowdata += @(,("Only allow Let's Encrypt verification",($Script:htmlsb),$SecureGatewayOnlyAllowLetsEncryptVerification,$htmlwhite))    
                                $rowdata += @(,("Enable RDP Port",($Script:htmlsb),$SecureGatewayEnableRDPPort,$htmlwhite))                                   $rowdata += @(,("Enable RDP Port",($Script:htmlsb),$GWEnableRDPPort,$htmlwhite))
                                $rowdata += @(,("RDP Port",($Script:htmlsb),$SecureGatewayRDPPort,$htmlwhite))                                   $rowdata += @(,("RDP Port",($Script:htmlsb),$GWRDPPort,$htmlwhite))
                                $rowdata += @(,("Enable Broadcast RAS Secure Client Gateway Address",($Script:htmlsb),$SecureGatewayEnableBroadcastRASSecureClientGatewayAddress,$htmlwhite))                                   $rowdata += @(,("Enable Broadcast RAS Secure Client Gateway Address",($Script:htmlsb),$GWEnableBroadcastRASSecureClientGatewayAddress,$htmlwhite))
                                $rowdata += @(,("Enable RDP UDP Data Tunneling",($Script:htmlsb),$SecureGatewayEnableRDPUPDDataTunneling,$htmlwhite))                                   $rowdata += @(,("Enable RDP UDP Data Tunneling",($Script:htmlsb),$GWEnableRDPUPDDataTunneling,$htmlwhite))
                                $rowdata += @(,("Enable Device Manager Port",($Script:htmlsb),$SecureGatewayEnableDeviceManagerPort,$htmlwhite))                                   $rowdata += @(,("Enable Client Manager Port",($Script:htmlsb),$GWEnableClientManagerPort,$htmlwhite))
                                $rowdata += @(,("Device Manager Port",($Script:htmlsb),$SecureGatewayDeviceManagerPort,$htmlwhite))                                   $rowdata += @(,("Client Manager Port",($Script:htmlsb),$GWClientManagerPort,$htmlwhite))
                                $rowdata += @(,("Enable RDP DOS Attack Filter",($Script:htmlsb),$SecureGatewayEnableRDPDOSAttackFilter,$htmlwhite))                                   $rowdata += @(,("Enable RDP DOS Attack Filter",($Script:htmlsb),$GWEnableRDPDOSAttackFilter,$htmlwhite))
 
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultSslTlsSettings.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultSslTlsSettings.ToString(); }) > $Null
 
                                If($SecureGatewayEnableHSTS -eq "False") <>                                 If($GWEnableHSTS -eq "False")
 
                                        $ScriptInformation.Add(@{Data = "Enforce HTTP strict transport security (HSTS)"; Value = $SecureGatewayEnableHSTS; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Enforce HTTP strict transport security (HSTS)"; Value = $GWEnableHSTS; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Browser caache time"; Value = "$SecureGatewayHSTSMaxage months"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Browser caache time"; Value = "$GWHSTSMaxage months"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Include subdomains"; Value = $SecureGatewayHSTSIncludeSubdomains; }) > $Null                                           $ScriptInformation.Add(@{Data = "Include subdomains"; Value = $GWHSTSIncludeSubdomains; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Preload"; Value = $SecureGatewayHSTSPreload; }) > $Null                                           $ScriptInformation.Add(@{Data = "Preload"; Value = $GWHSTSPreload; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Enable SSL"; Value = $SecureGatewayEnableSSL; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Enable SSL"; Value = $GWEnableSSL; }) > $Null
                                $ScriptInformation.Add(@{Data = "on Port"; Value = $SecureGatewayEnableSSLOnPort; }) > $Null                                   $ScriptInformation.Add(@{Data = "on Port"; Value = $GWEnableSSLOnPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "Accepted SSL Versions"; Value = $SecureGatewayAcceptedSSLVersions; }) > $Null                                   $ScriptInformation.Add(@{Data = "Accepted SSL Versions"; Value = $GWAcceptedSSLVersions; }) > $Null
                                $ScriptInformation.Add(@{Data = "Cipher Strength"; Value = $SecureGatewayCipherStrength; }) > $Null                                   $ScriptInformation.Add(@{Data = "Cipher Strength"; Value = $GWCipherStrength; }) > $Null
                                $ScriptInformation.Add(@{Data = "Cipher"; Value = $SecureGatewayCipher; }) > $Null                                   $ScriptInformation.Add(@{Data = "Cipher"; Value = $GWCipher; }) > $Null
                                $ScriptInformation.Add(@{Data = "Use ciphers according to server preference"; Value = $SecureGatewayCipherPreference; }) > $Null                                   $ScriptInformation.Add(@{Data = "Use ciphers according to server preference"; Value = $GWCipherPreference; }) > $Null
                                $ScriptInformation.Add(@{Data = "Certificates"; Value = $SecureGatewayCertificates; }) > $Null                                   $ScriptInformation.Add(@{Data = "Certificates"; Value = $GWCertificates; }) > $Null
 
                                Line 3 "Inherit default settings`t`t  : " $SecureGateway.InheritDefaultSslTlsSettings.ToString() <>                                 Line 3 "Inherit default settings`t`t  : " $GW.InheritDefaultSslTlsSettings.ToString()
 
                                If($SecureGatewayEnableHSTS -eq "False") <>                                 If($GWEnableHSTS -eq "False")
 
                                        Line 3 "Enforce HTTP strict transport security`t  : " $SecureGatewayEnableHSTS <>                                         Line 3 "Enforce HTTP strict transport security`t  : " $GWEnableHSTS
                                        Line 3 "Browser caache time`t`t`t  : " "$SecureGatewayHSTSMaxage months"                                           Line 3 "Browser caache time`t`t`t  : " "$GWHSTSMaxage months"
                                        Line 3 "Include subdomains`t`t`t  : " $SecureGatewayHSTSIncludeSubdomains                                           Line 3 "Include subdomains`t`t`t  : " $GWHSTSIncludeSubdomains
                                        Line 3 "Preload`t`t`t`t`t  : " $SecureGatewayHSTSPreload                                           Line 3 "Preload`t`t`t`t`t  : " $GWHSTSPreload
 
                                Line 3 "Enable SSL`t`t`t`t  : " $SecureGatewayEnableSSL <>                                 Line 3 "Enable SSL`t`t`t`t  : " $GWEnableSSL
                                Line 3 "on Port`t`t`t`t`t  : " $SecureGatewayEnableSSLOnPort                                   Line 3 "on Port`t`t`t`t`t  : " $GWEnableSSLOnPort
                                Line 3 "Accepted SSL Versions`t`t`t  : " $SecureGatewayAcceptedSSLVersions                                   Line 3 "Accepted SSL Versions`t`t`t  : " $GWAcceptedSSLVersions
                                Line 3 "Cipher Strength`t`t`t`t  : " $SecureGatewayCipherStrength                                   Line 3 "Cipher Strength`t`t`t`t  : " $GWCipherStrength
                                Line 3 "Cipher`t`t`t`t`t  : " $SecureGatewayCipher                                   Line 3 "Cipher`t`t`t`t`t  : " $GWCipher
                                Line 3 "Use ciphers according to server preference: " $SecureGatewayCipherPreference                                   Line 3 "Use ciphers according to server preference: " $GWCipherPreference
                                Line 3 "Certificates`t`t`t`t  : " $SecureGatewayCertificates                                   Line 3 "Certificates`t`t`t`t  : " $GWCertificates
 
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultSslTlsSettings.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultSslTlsSettings.ToString(),$htmlwhite)
 
                                If($SecureGatewayEnableHSTS -eq "False") <>                                 If($GWEnableHSTS -eq "False")
 
                                        $rowdata += @(,("Enforce HTTP strict transport security (HSTS)",($Script:htmlsb),$SecureGatewayEnableHSTS,$htmlwhite)) <>                                         $rowdata += @(,("Enforce HTTP strict transport security (HSTS)",($Script:htmlsb),$GWEnableHSTS,$htmlwhite))
                                        $rowdata += @(,("Browser caache time",($Script:htmlsb),"$SecureGatewayHSTSMaxage months",$htmlwhite))                                           $rowdata += @(,("Browser caache time",($Script:htmlsb),"$GWHSTSMaxage months",$htmlwhite))
                                        $rowdata += @(,("Include subdomains",($Script:htmlsb),$SecureGatewayHSTSIncludeSubdomains,$htmlwhite))                                           $rowdata += @(,("Include subdomains",($Script:htmlsb),$GWHSTSIncludeSubdomains,$htmlwhite))
                                        $rowdata += @(,("Preload",($Script:htmlsb),$SecureGatewayHSTSPreload,$htmlwhite))                                           $rowdata += @(,("Preload",($Script:htmlsb),$GWHSTSPreload,$htmlwhite))
 
                                $rowdata += @(,("Enable SSL",($Script:htmlsb),$SecureGatewayEnableSSL,$htmlwhite)) <>                                 $rowdata += @(,("Enable SSL",($Script:htmlsb),$GWEnableSSL,$htmlwhite))
                                $rowdata += @(,("on Port",($Script:htmlsb),$SecureGatewayEnableSSLOnPort,$htmlwhite))                                   $rowdata += @(,("on Port",($Script:htmlsb),$GWEnableSSLOnPort,$htmlwhite))
                                $rowdata += @(,("Accepted SSL Versions",($Script:htmlsb),$SecureGatewayAcceptedSSLVersions,$htmlwhite))                                   $rowdata += @(,("Accepted SSL Versions",($Script:htmlsb),$GWAcceptedSSLVersions,$htmlwhite))
                                $rowdata += @(,("Cipher Strength",($Script:htmlsb),$SecureGatewayCipherStrength,$htmlwhite))                                   $rowdata += @(,("Cipher Strength",($Script:htmlsb),$GWCipherStrength,$htmlwhite))
                                $rowdata += @(,("Cipher",($Script:htmlsb),$SecureGatewayCipher,$htmlwhite))                                   $rowdata += @(,("Cipher",($Script:htmlsb),$GWCipher,$htmlwhite))
                                $rowdata += @(,("Use ciphers according to server preference",($Script:htmlsb),$SecureGatewayCipherPreference,$htmlwhite))                                   $rowdata += @(,("Use ciphers according to server preference",($Script:htmlsb),$GWCipherPreference,$htmlwhite))
                                $rowdata += @(,("Certificates",($Script:htmlsb),$SecureGatewayCertificates,$htmlwhite))                                   $rowdata += @(,("Certificates",($Script:htmlsb),$GWCertificates,$htmlwhite))
 
                                WriteWordLine 4 0 "User Portal" <>                                 WriteWordLine 4 0 "HTML5"
 
                                Line 2 "User Portal" <>                                 Line 2 "HTML5"
 
                        If($SecureGateway.InheritDefaultUserPortalSettings) <>                         If($GW.InheritDefaultHTML5Settings)
 
                                $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null <>                                 $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
 
                                If($? -and $Null -ne $SecureGatewayDefaults) <>                                 If($? -and $Null -ne $GWDefaults)
 
                                        $SecureGatewayEnableUserPortalClient = $SecureGatewayDefaults.EnableUserPortal.ToString() <>                                         $GWEnableHTML5Client = $GWDefaults.EnableHTML5.ToString()
 
                                        Switch($SecureGatewayDefaults.LaunchMethod) <>                                         Switch($GWDefaults.LaunchMethod)
 
                                                "ParallelsClientAndWebClient"   {$SecureGatewayLaunchSessionsUsing = "Parallels Client with fallback to Browser"; Break} <>                                                 "ParallelsClientAndHTML5"       {$GWLaunchSessionsUsing = "Launch apps with Parallels Client & Fallback to HTML5"; Break}
                                                "ParallelsClient"                               {$SecureGatewayLaunchSessionsUsing = "Parallels Client only"; Break}                                                   "ParallelsClient"                       {$GWLaunchSessionsUsing = "Launch apps with Parallels Client"; Break}
                                                "WebClient"                                             {$SecureGatewayLaunchSessionsUsing = "Browser Only"; Break}                                                   "HTML5"                                         {$GWLaunchSessionsUsing = "Launch apps in Browser only (HTML5 Only)"; Break}
                                                Default                                                 {$SecureGatewayLaunchSessionsUsing = "Unable to determine Launch sessions using: $($SecureGatewayDefaults.LaunchMethod)"; Break}                                                   Default                                         {$GWLaunchSessionsUsing = "Unable to determine Launch sessions using: $($GWDefaults.LaunchMethod)"; Break}
 
                                        Switch ($SecureGatewayDefaults.FileTransferMode) <>                                         Switch ($GWDefaults.FileTransferMode)
 
                                                "Bidirectional"         {$SecureGatewayFileTransferMode = "Bidirectional"; Break} <>                                                 "Bidirectional"         {$GWFileTransferMode = "Bidirectional"; Break}
                                                "Disabled"                      {$SecureGatewayFileTransferMode = "Disabled"; Break}                                                   "Disabled"                      {$GWFileTransferMode = "Disabled"; Break}
                                                "ClientToServer"        {$SecureGatewayFileTransferMode = "Client to server only"; Break}                                                   "ClientToServer"        {$GWFileTransferMode = "Client to server only"; Break}
                                                "ServerToClient"        {$SecureGatewayFileTransferMode = "Server to client only"; Break}                                                   "ServerToClient"        {$GWFileTransferMode = "Server to client only"; Break}
                                                Default                         {$SecureGatewayFileTransferMode = "Unable to determine File Transfer mode: $($SecureGatewayDefaults.FileTransferMode)"; Break}                                                   Default                         {$GWFileTransferMode = "Unable to determine File Transfer mode: $($GWDefaults.FileTransferMode)"; Break}
 
                                        Switch ($SecureGatewayDefaults.ClipboardDirection) <>                                         Switch ($GWDefaults.ClipboardDirection)
 
                                                "Bidirectional"         {$SecureGatewayClipboardTransferMode = "Bidirectional"; Break} <>                                                 "Bidirectional"         {$GWClipboardTransferMode = "Bidirectional"; Break}
                                                "Disabled"                      {$SecureGatewayClipboardTransferMode = "Disabled"; Break}                                                   "Disabled"                      {$GWClipboardTransferMode = "Disabled"; Break}
                                                "ClientToServer"        {$SecureGatewayClipboardTransferMode = "Client to server only"; Break}                                                   "ClientToServer"        {$GWClipboardTransferMode = "Client to server only"; Break}
                                                "ServerToClient"        {$SecureGatewayClipboardTransferMode = "Server to client only"; Break}                                                   "ServerToClient"        {$GWClipboardTransferMode = "Server to client only"; Break}
                                                Default                         {$SecureGatewayClipboardTransferMode = "Unable to determine Clipboard mode: $($SecureGatewayDefaults.ClipboardDirection)"; Break}                                                   Default                         {$GWClipboardTransferMode = "Unable to determine Clipboard mode: $($GWDefaults.ClipboardDirection)"; Break}
 
                                        $SecureGatewayAllowLaunchMethod          = $SecureGatewayDefaults.AllowLaunchMethod.ToString() <>                                         $GWAllowLaunchMethod          = $GWDefaults.AllowLaunchMethod.ToString()
                                        $SecureGatewayAllowAppsInNewTab          = $SecureGatewayDefaults.AllowAppsInNewTab.ToString()                                           $GWAllowAppsInNewTab          = $GWDefaults.AllowAppsInNewTab.ToString()
                                        $SecureGatewayUsePreWin2000LoginFormat   = $SecureGatewayDefaults.UsePreWin2000LoginFormat.ToString()                                           $GWUsePreWin2000LoginFormat   = $GWDefaults.UsePreWin2000LoginFormat.ToString()
                                        $SecureGatewayAllowEmbed                 = $SecureGatewayDefaults.AllowEmbed.ToString()                                           $GWAllowEmbed                 = $GWDefaults.AllowEmbed.ToString()
                                        $SecureGatewayAllowFileTransfer          = $SecureGatewayDefaults.AllowFileTransfer.ToString()                                           $GWAllowFileTransfer          = $GWDefaults.AllowFileTransfer.ToString()
                                        $SecureGatewayAllowClipboard             = $SecureGatewayDefaults.AllowClipboard.ToString()                                           $GWAllowClipboard             = $GWDefaults.AllowClipboard.ToString()
                                        $SecureGatewayAllowCORS                  = $SecureGatewayDefaults.AllowCORS                                           $GWAllowCORS                  = $GWDefaults.AllowCORS
                                        $SecureGatewayAllowedDomainsForCORS      = $SecureGatewayDefaults.AllowedDomainsForCORS                                           $GWAllowedDomainsForCORS      = $GWDefaults.AllowedDomainsForCORS
                                        $SecureGatewayBrowserCacheTimeInMonths   = $SecureGatewayDefaults.BrowserCacheTimeInMonths                                           $GWBrowserCacheTimeInMonths   = $GWDefaults.BrowserCacheTimeInMonths
                                        $SecureGatewayEnableAlternateNLBHostname = $SecureGatewayDefaults.EnableAlternateNLBHost.ToString()                                           $GWEnableAlternateNLBHostname = $GWDefaults.EnableAlternateNLBHost.ToString()
                                        $SecureGatewayAlternameNLBHostname       = $SecureGatewayDefaults.AlternateNLBHost                                           $GWAlternameNLBHostname       = $GWDefaults.AlternateNLBHost
                                        $SecureGatewayEnableAlternateNLBPort     = $SecureGatewayDefaults.EnableAlternateNLBPort.ToString()                                           $GWEnableAlternateNLBPort     = $GWDefaults.EnableAlternateNLBPort.ToString()
                                        $SecureGatewayAlternateNLBPort           = $SecureGatewayDefaults.AlternateNLBPort.ToString()                                           $GWAlternateNLBPort           = $GWDefaults.AlternateNLBPort.ToString()
 
                                        $SecureGatewayEnableUserPortalClient     = "True" <>                                         $GWEnableHTML5Client          = "True"
                                        $SecureGatewayLaunchSessionsUsing        = "Parallels Client with gallback to Browser"                                           $GWLaunchSessionsUsing        = "Launch apps with Parallels CLient & Fallback to HTML5"
                                        $SecureGatewayAllowLaunchMethod          = "True"                                           $GWAllowLaunchMethod          = "True"
                                        $SecureGatewayAllowAppsInNewTab          = "False"                                           $GWAllowAppsInNewTab          = "False"
                                        $SecureGatewayUsePreWin2000LoginFormat   = "True"                                           $GWUsePreWin2000LoginFormat   = "True"
                                        $SecureGatewayAllowEmbed                 = "False"                                           $GWAllowEmbed                 = "False"
                                        $SecureGatewayAllowFileTransfer          = "True"                                           $GWAllowFileTransfer          = "True"
                                        $SecureGatewayAllowClipboard             = "True"                                           $GWAllowClipboard             = "True"
                                        $SecureGatewayAllowCORS                  = "False"                                           $GWAllowCORS                  = "False"
                                        $SecureGatewayAllowedDomainsForCORS      = @()                                           $GWAllowedDomainsForCORS      = @()
                                        $SecureGatewayBrowserCacheTimeInMonths   = 12                                           $GWBrowserCacheTimeInMonths   = 12
                                        $SecureGatewayEnableAlternateNLBHostname = "False"                                           $GWEnableAlternateNLBHostname = "False"
                                        $SecureGatewayAlternameNLBHostname       = ""                                           $GWAlternameNLBHostname       = ""
                                        $SecureGatewayEnableAlternateNLBPort     = "False"                                           $GWEnableAlternateNLBPort     = "False"
                                        $SecureGatewayAlternateNLBPort           = "8443"                                           $GWAlternateNLBPort           = "8443"
                                        $SecureGatewayClipboardTransferMode      = "Bidirectional"                                           $GWClipboardTransferMode      = "Bidirectional"
                                            $GWClipboardTransferMode      = "Bidirectional"
 
                                $SecureGatewayEnableUserPortalClient = $SecureGateway.EnableUserPortal.ToString() <>                                 $GWEnableHTML5Client = $GW.EnableHTML5.ToString()
 
                                Switch($SecureGatewayDefaults.LaunchMethod) <>                                 Switch($GW.LaunchMethod)
 
                                        "ParallelsClientAndWebClient"   {$SecureGatewayLaunchSessionsUsing = "Parallels Client with fallback to Browser"; Break} <>                                         "ParallelsClientAndHTML5"       {$GWLaunchSessionsUsing = "Launch apps with Parallels Client & Fallback to HTML5"; Break}
                                        "ParallelsClient"                               {$SecureGatewayLaunchSessionsUsing = "Parallels Client only"; Break}                                           "ParallelsClient"                       {$GWLaunchSessionsUsing = "Launch apps with Parallels Client"; Break}
                                        "WebClient"                                             {$SecureGatewayLaunchSessionsUsing = "Browser Only"; Break}                                           "HTML5"                                         {$GWLaunchSessionsUsing = "Launch apps in Browser only (HTML5 Only)"; Break}
                                        Default                                                 {$SecureGatewayLaunchSessionsUsing = "Unable to determine Launch sessions using: $($SecureGatewayDefaults.LaunchMethod)"; Break}                                           Default                                         {$GWLaunchSessionsUsing = "Unable to determine Launch sessions using: $($GW.LaunchMethod)"; Break}
 
                                Switch ($SecureGatewayDefaults.FileTransferMode) <>                                 Switch ($GW.FileTransferMode)
 
                                        "Bidirectional"         {$SecureGatewayFileTransferMode = "Bidirectional"; Break} <>                                         "Bidirectional"         {$GWFileTransferMode = "Bidirectional"; Break}
                                        "Disabled"                      {$SecureGatewayFileTransferMode = "Disabled"; Break}                                           "Disabled"                      {$GWFileTransferMode = "Disabled"; Break}
                                        "ClientToServer"        {$SecureGatewayFileTransferMode = "Client to server only"; Break}                                           "ClientToServer"        {$GWFileTransferMode = "Client to server only"; Break}
                                        "ServerToClient"        {$SecureGatewayFileTransferMode = "Server to client only"; Break}                                           "ServerToClient"        {$GWFileTransferMode = "Server to client only"; Break}
                                        Default                         {$SecureGatewayFileTransferMode = "Unable to determine File Transfer mode: $($SecureGatewayDefaults.FileTransferMode)"; Break}                                           Default                         {$GWFileTransferMode = "Unable to determine File Transfer mode: $($GW.FileTransferMode)"; Break}
 
                                Switch ($SecureGatewayDefaults.ClipboardDirection) <>                                 Switch ($GW.ClipboardDirection)
 
                                        "Bidirectional"         {$SecureGatewayClipboardTransferMode = "Bidirectional"; Break} <>                                         "Bidirectional"         {$GWClipboardTransferMode = "Bidirectional"; Break}
                                        "Disabled"                      {$SecureGatewayClipboardTransferMode = "Disabled"; Break}                                           "Disabled"                      {$GWClipboardTransferMode = "Disabled"; Break}
                                        "ClientToServer"        {$SecureGatewayClipboardTransferMode = "Client to server only"; Break}                                           "ClientToServer"        {$GWClipboardTransferMode = "Client to server only"; Break}
                                        "ServerToClient"        {$SecureGatewayClipboardTransferMode = "Server to client only"; Break}                                           "ServerToClient"        {$GWClipboardTransferMode = "Server to client only"; Break}
                                        Default                         {$SecureGatewayClipboardTransferMode = "Unable to determine Clipboard mode: $($SecureGatewayDefaults.ClipboardDirection)"; Break}                                           Default                         {$GWClipboardTransferMode = "Unable to determine Clipboard mode: $($GW.ClipboardDirection)"; Break}
 
                                $SecureGatewayAllowLaunchMethod          = $SecureGateway.AllowLaunchMethod.ToString() <>                                 $GWAllowLaunchMethod          = $GW.AllowLaunchMethod.ToString()
                                $SecureGatewayAllowAppsInNewTab          = $SecureGateway.AllowAppsInNewTab.ToString()                                   $GWAllowAppsInNewTab          = $GW.AllowAppsInNewTab.ToString()
                                $SecureGatewayUsePreWin2000LoginFormat   = $SecureGateway.UsePreWin2000LoginFormat.ToString()                                   $GWUsePreWin2000LoginFormat   = $GW.UsePreWin2000LoginFormat.ToString()
                                $SecureGatewayAllowEmbed                 = $SecureGateway.AllowEmbed.ToString()                                   $GWAllowEmbed                 = $GW.AllowEmbed.ToString()
                                $SecureGatewayAllowFileTransfer          = $SecureGateway.AllowFileTransfer                                   $GWAllowFileTransfer          = $GW.AllowFileTransfer
                                $SecureGatewayAllowClipboard             = $SecureGateway.AllowClipboard                                   $GWAllowClipboard             = $GW.AllowClipboard
                                $SecureGatewayAllowCORS                  = $SecureGateway.AllowCORS                                   $GWAllowCORS                  = $GW.AllowCORS
                                $SecureGatewayAllowedDomainsForCORS      = $SecureGateway.AllowedDomainsForCORS                                   $GWAllowedDomainsForCORS      = $GW.AllowedDomainsForCORS
                                $SecureGatewayBrowserCacheTimeInMonths   = $SecureGateway.BrowserCacheTimeInMonths                                   $GWBrowserCacheTimeInMonths   = $GW.BrowserCacheTimeInMonths
                                $SecureGatewayEnableAlternateNLBHostname = $SecureGateway.EnableAlternateNLBHost.ToString()                                   $GWEnableAlternateNLBHostname = $GW.EnableAlternateNLBHost.ToString()
                                $SecureGatewayAlternameNLBHostname       = $SecureGateway.AlternateNLBHost                                   $GWAlternameNLBHostname       = $GW.AlternateNLBHost
                                $SecureGatewayEnableAlternateNLBPort     = $SecureGateway.EnableAlternateNLBPort.ToString()                                   $GWEnableAlternateNLBPort     = $GW.EnableAlternateNLBPort.ToString()
                                $SecureGatewayAlternateNLBPort           = $SecureGateway.AlternateNLBPort.ToString()                                   $GWAlternateNLBPort           = $GW.AlternateNLBPort.ToString()
 
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultUserPortalSettings.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultHTML5Settings.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable User Portal"; Value = $SecureGatewayEnableUserPortalClient; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable HTML5 Client"; Value = $GWEnableHTML5Client; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "     Launch sessions using"; Value = $SecureGatewayLaunchSessionsUsing; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "     Launch sessions using"; Value = $GWLaunchSessionsUsing; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Allow user to select a launch method"; Value = $SecureGatewayAllowLaunchMethod; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow user to select a launch method"; Value = $GWAllowLaunchMethod; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $SecureGatewayAllowAppsInNewTab; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $GWAllowAppsInNewTab; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Use Pre Windows 2000 login format"; Value = $SecureGatewayUsePreWin2000LoginFormat; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Use Pre Windows 2000 login format"; Value = $GWUsePreWin2000LoginFormat; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Allow embedding of User Portal into other web pages"; Value = $SecureGatewayAllowEmbed; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow embedding of Parallels HTML5 Client into other web pages"; Value = $GWAllowEmbed; }) > $Null
     
                                $ScriptInformation.Add(@{Data = "     Allow file transfer command"; Value = $SecureGatewayAllowFileTransfer.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow file transfer command"; Value = $GWAllowFileTransfer.ToString(); }) > $Null
                                If($SecureGatewayAllowFileTransfer)                                   If($GWAllowFileTransfer)
 
                                        $ScriptInformation.Add(@{Data = "          Direction"; Value = $SecureGatewayFileTransferMode; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "          Direction"; Value = $GWFileTransferMode; }) > $Null
 
  <>  
                                $ScriptInformation.Add(@{Data = "     Allow clipboard command"; Value = $SecureGatewayAllowClipboard.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow clipboard command"; Value = $GWAllowClipboard.ToString(); }) > $Null
                                If($SecureGatewayAllowClipboard)                                   If($GWAllowClipboard)
 
                                        $ScriptInformation.Add(@{Data = "          Clipboard Redirection"; Value = $SecureGatewayClipboardTransferMode; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "          Clipboard Redirection"; Value = $GWClipboardTransferMode; }) > $Null
 
  <>  
                                $ScriptInformation.Add(@{Data = "     Allow cross-origin resource sharing"; Value = $SecureGatewayAllowCORS.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow cross-origin resource sharing"; Value = $GWAllowCORS.ToString(); }) > $Null
                                If($SecureGatewayAllowCORS)                                   If($GWAllowCORS)
 
                                        ForEach($Domain in $SecureGatewayAllowedDomainsForCORS) <>                                         ForEach($Domain in $GWAllowedDomainsForCORS)
 
                                        $ScriptInformation.Add(@{Data = "     Browser cache time"; Value = "$($SecureGatewayBrowserCacheTimeInMonths.ToString()) months"; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "     Browser cache time"; Value = "$($GWBrowserCacheTimeInMonths.ToString()) months"; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "     Use alternate hostname"; Value = $SecureGatewayEnableAlternateNLBHostname; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "     Use alternate hostname"; Value = $GWEnableAlternateNLBHostname; }) > $Null
                                If($SecureGatewayEnableAlternateNLBHostname -eq "True")                                   If($GWEnableAlternateNLBHostname -eq "True")
 
                                        $ScriptInformation.Add(@{Data = ""; Value = $SecureGatewayAlternameNLBHostname; }) > $Null <>                                         $ScriptInformation.Add(@{Data = ""; Value = $GWAlternameNLBHostname; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "     Use alternate port"; Value = $SecureGatewayEnableAlternateNLBPort; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "     Use alternate port"; Value = $GWEnableAlternateNLBPort; }) > $Null
                                If($SecureGatewayEnableAlternateNLBPort -eq "True")                                   If($GWEnableAlternateNLBPort -eq "True")
 
                                        $ScriptInformation.Add(@{Data = ""; Value = $SecureGatewayAlternateNLBPort; }) > $Null <>                                         $ScriptInformation.Add(@{Data = ""; Value = $GWAlternateNLBPort; }) > $Null
 
                                Line 3 "Inherit default settings`t`t`t: " $SecureGateway.InheritDefaultUserPortalSettings.ToString() <>                                 Line 3 "Inherit default settings`t`t`t: " $GW.InheritDefaultHTML5Settings.ToString()
                                Line 3 "Enable User Portal`t`t`t`t: " $SecureGatewayEnableUserPortalClient                                   Line 3 "Enable HTML5 Client`t`t`t`t: " $GWEnableHTML5Client
 
                                Line 4 "Launch sessions using`t`t`t: " $SecureGatewayLaunchSessionsUsing <>                                 Line 4 "Launch sessions using`t`t`t: " $GWLaunchSessionsUsing
                                Line 4 "Allow user to select a launch method`t: " $SecureGatewayAllowLaunchMethod                                   Line 4 "Allow user to select a launch method`t: " $GWAllowLaunchMethod
                                Line 4 "Allow opening applications in a new tab`t: " $SecureGatewayAllowAppsInNewTab                                   Line 4 "Allow opening applications in a new tab`t: " $GWAllowAppsInNewTab
                                Line 4 "Use Pre Windows 2000 login format`t: " $SecureGatewayUsePreWin2000LoginFormat                                   Line 4 "Use Pre Windows 2000 login format`t: " $GWUsePreWin2000LoginFormat
                                Line 4 "Allow embedding of User Portal"                                   Line 4 "Allow embedding of Parallels HTML5"
                                Line 4 "into other web pages`t`t`t: " $SecureGatewayAllowEmbed                                   Line 4 "Client into other web pages`t`t: " $GWAllowEmbed
 
                                Line 4 "Allow file transfer command`t`t: " $SecureGatewayAllowFileTransfer.ToString() <>                                 Line 4 "Allow file transfer command`t`t: " $GWAllowFileTransfer.ToString()
                                If($SecureGateway.AllowFileTransfer)                                   If($GW.AllowFileTransfer)
 
                                        Line 5 "Direction`t`t`t: " $SecureGatewayFileTransferMode <>                                         Line 5 "Direction: " $GWFileTransferMode
 
                                Line 4 "Allow clipboard command`t`t`t: " $SecureGatewayAllowClipboard.ToString() <>                                 Line 4 "Allow clipboard command`t`t`t: " $GWAllowClipboard.ToString()
                                If($SecureGateway.AllowClipboard)                                   If($GW.AllowClipboard)
 
                                        Line 5 "Clipboard Redirection`t`t: " $SecureGatewayClipboardTransferMode <>                                         Line 5 "Clipboard Redirection: " $GWClipboardTransferMode
 
                                Line 4 "Allow cross-origin resource sharing`t: " $SecureGatewayAllowCORS.ToString() <>                                 Line 4 "Allow cross-origin resource sharing`t: " $GWAllowCORS.ToString()
                                If($SecureGatewayAllowCORS)                                   If($GWAllowCORS)
 
                                        ForEach($Domain in $SecureGatewayAllowedDomainsForCORS) <>                                         ForEach($Domain in $GWAllowedDomainsForCORS)
 
                                        Line 6 "Browser cache time      : " "$($SecureGatewayBrowserCacheTimeInMonths.ToString()) months" <>                                         Line 6 "Browser cache time      : " "$($GWBrowserCacheTimeInMonths.ToString()) months"
 
                                Line 4 "Use alternate hostname`t`t: " $SecureGatewayEnableAlternateNLBHostname <>                                 Line 4 "Use alternate hostname`t`t: " $GWEnableAlternateNLBHostname
                                If($SecureGatewayEnableAlternateNLBHostname -eq "True")                                   If($GWEnableAlternateNLBHostname -eq "True")
 
                                        Line 8 $SecureGatewayAlternameNLBHostname <>                                         Line 8 $GWAlternameNLBHostname
 
                                Line 4 "Use alternate port`t`t: " $SecureGatewayEnableAlternateNLBPort <>                                 Line 4 "Use alternate port`t`t: " $GWEnableAlternateNLBPort
                                If($SecureGatewayEnableAlternateNLBPort -eq "True")                                   If($GWEnableAlternateNLBPort -eq "True")
 
                                        Line 8 $SecureGatewayAlternateNLBPort <>                                         Line 8 $GWAlternateNLBPort
 
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultUserPortalSettings.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultHTML5Settings.ToString(),$htmlwhite)
                                $rowdata += @(,("Enable User Portal",($Script:htmlsb),$SecureGatewayEnableUserPortalClient,$htmlwhite))                                   $rowdata += @(,("Enable HTML5 Client",($Script:htmlsb),$GWEnableHTML5Client,$htmlwhite))
 
                                $rowdata += @(,("     Launch sessions using",($Script:htmlsb),$SecureGatewayLaunchSessionsUsing,$htmlwhite)) <>                                 $rowdata += @(,("     Launch sessions using",($Script:htmlsb),$GWLaunchSessionsUsing,$htmlwhite))
                                $rowdata += @(,("     Allow user to select a launch method",($Script:htmlsb),$SecureGatewayAllowLaunchMethod,$htmlwhite))                                   $rowdata += @(,("     Allow user to select a launch method",($Script:htmlsb),$GWAllowLaunchMethod,$htmlwhite))
                                $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb),$SecureGatewayAllowAppsInNewTab,$htmlwhite))                                   $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb),$GWAllowAppsInNewTab,$htmlwhite))
                                $rowdata += @(,("     Use Pre Windows 2000 login format",($Script:htmlsb),$SecureGatewayUsePreWin2000LoginFormat,$htmlwhite))                                   $rowdata += @(,("     Use Pre Windows 2000 login format",($Script:htmlsb),$GWUsePreWin2000LoginFormat,$htmlwhite))
                                $rowdata += @(,("     Allow embedding of User Portal into other web pages",($Script:htmlsb),$SecureGatewayAllowEmbed,$htmlwhite))                                   $rowdata += @(,("     Allow embedding of Parallels HTML5 Client into other web pages",($Script:htmlsb),$GWAllowEmbed,$htmlwhite))
 
                                $rowdata += @(,("     Allow file transfer command",($Script:htmlsb),$SecureGatewayAllowFileTransfer.ToString(),$htmlwhite)) <>                                 $rowdata += @(,("     Allow file transfer command",($Script:htmlsb),$GWAllowFileTransfer.ToString(),$htmlwhite))
                                If($SecureGateway.AllowFileTransfer)                                   If($GW.AllowFileTransfer)
 
                                        $rowdata += @(,("          Direction",($Script:htmlsb),$SecureGatewayFileTransferMode,$htmlwhite)) <>                                         $rowdata += @(,("          Direction",($Script:htmlsb),$GWFileTransferMode,$htmlwhite))
 
                                $rowdata += @(,("     Allow clipboard command",($Script:htmlsb),$SecureGatewayAllowClipboard.ToString(),$htmlwhite)) <>                                 $rowdata += @(,("     Allow clipboard command",($Script:htmlsb),$GWAllowClipboard.ToString(),$htmlwhite))
                                If($SecureGateway.AllowClipboard)                                   If($GW.AllowClipboard)
 
                                        $rowdata += @(,("          Clipboard Redirection",($Script:htmlsb),$SecureGatewayClipboardTransferMode,$htmlwhite)) <>                                         $rowdata += @(,("          Clipboard Redirection",($Script:htmlsb),$GWClipboardTransferMode,$htmlwhite))
 
                                $rowdata += @(,("     Allow cross-origin resource sharing",($Script:htmlsb),$SecureGatewayAllowCORS.ToString(),$htmlwhite)) <>                                 $rowdata += @(,("     Allow cross-origin resource sharing",($Script:htmlsb),$GWAllowCORS.ToString(),$htmlwhite))
                                If($SecureGatewayAllowCORS)                                   If($GWAllowCORS)
 
                                        ForEach($Domain in $SecureGatewayAllowedDomainsForCORS) <>                                         ForEach($Domain in $GWAllowedDomainsForCORS)
 
                                        $rowdata += @(,("     Browser cache time",($Script:htmlsb),"$($SecureGatewayBrowserCacheTimeInMonths.ToString()) months",$htmlwhite)) <>                                         $rowdata += @(,("     Browser cache time",($Script:htmlsb),"$($GWBrowserCacheTimeInMonths.ToString()) months",$htmlwhite))
 
                                $rowdata += @(,("     Use alternate hostname",($Script:htmlsb),$SecureGatewayEnableAlternateNLBHostname,$htmlwhite)) <>                                 $rowdata += @(,("     Use alternate hostname",($Script:htmlsb),$GWEnableAlternateNLBHostname,$htmlwhite))
                                If($SecureGatewayEnableAlternateNLBHostname -eq "True")                                   If($GWEnableAlternateNLBHostname -eq "True")
 
                                        $rowdata += @(,("",($Script:htmlsb),$SecureGatewayAlternameNLBHostname,$htmlwhite)) <>                                         $rowdata += @(,("",($Script:htmlsb),$GWAlternameNLBHostname,$htmlwhite))
 
                                $rowdata += @(,("     Use alternate port",($Script:htmlsb),$SecureGatewayEnableAlternateNLBPort,$htmlwhite)) <>                                 $rowdata += @(,("     Use alternate port",($Script:htmlsb),$GWEnableAlternateNLBPort,$htmlwhite))
                                If($SecureGatewayEnableAlternateNLBPort -eq "True")                                   If($GWEnableAlternateNLBPort -eq "True")
 
                                        $rowdata += @(,("",($Script:htmlsb),$SecureGatewayAlternateNLBPort,$htmlwhite)) <>                                         $rowdata += @(,("",($Script:htmlsb),$GWAlternateNLBPort,$htmlwhite))
 
                                $msg = "User Portal" <>                                 $msg = "HTML5"
 
                        If($SecureGateway.InheritDefaultWyseSettings) <>                         If($GW.InheritDefaultWyseSettings)
 
                                $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null <>                                 $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
 
                                If($? -and $Null -ne $SecureGatewayDefaults) <>                                 If($? -and $Null -ne $GWDefaults)
 
                                        $SecureGatewayEnableWyse          = $SecureGatewayDefaults.EnableWyseSupport.ToString() <>                                         $GWEnableWyse          = $GWDefaults.EnableWyseSupport.ToString()
                                        $SecureGatewayDisableWyseCertWarn = $SecureGatewayDefaults.DisableWyseCertWarn.ToString()                                           $GWDisableWyseCertWarn = $GWDefaults.DisableWyseCertWarn.ToString()
 
                                        $SecureGatewayEnableWyse          = "True" <>                                         $GWEnableWyse          = "True"
                                        $SecureGatewayDisableWyseCertWarn = "False"                                           $GWDisableWyseCertWarn = "False"
 
                                $SecureGatewayEnableWyse          = $SecureGateway.EnableWyseSupport.ToString() <>                                 $GWEnableWyse          = $GW.EnableWyseSupport.ToString()
                                $SecureGatewayDisableWyseCertWarn = $SecureGateway.DisableWyseCertWarn.ToString()                                   $GWDisableWyseCertWarn = $GW.DisableWyseCertWarn.ToString()
 
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultWyseSettings.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultWyseSettings.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable Wyse ThinOS Support"; Value = $SecureGatewayEnableWyse; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable Wyse ThinOS Support"; Value = $GWEnableWyse; }) > $Null
                                $ScriptInformation.Add(@{Data = "Do not warn if server certificate is not verified"; Value = $SecureGatewayDisableWyseCertWarn; }) > $Null                                   $ScriptInformation.Add(@{Data = "Do not warn if server certificate is not verified"; Value = $GWDisableWyseCertWarn; }) > $Null
 
                                Line 3 "Inherit default settings`t`t`t : " $SecureGateway.InheritDefaultWyseSettings.ToString() <>                                 Line 3 "Inherit default settings`t`t`t : " $GW.InheritDefaultWyseSettings.ToString()
                                Line 3 "Enable Wyse ThinOS Support`t`t`t : " $SecureGatewayEnableWyse                                   Line 3 "Enable Wyse ThinOS Support`t`t`t : " $GWEnableWyse
                                Line 3 "Do not warn if server certificate is not verified: " $SecureGatewayDisableWyseCertWarn                                   Line 3 "Do not warn if server certificate is not verified: " $GWDisableWyseCertWarn
 
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultWyseSettings.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultWyseSettings.ToString(),$htmlwhite)
                                $rowdata += @(,("Enable Wyse ThinOS Support",($Script:htmlsb),$SecureGatewayEnableWyse,$htmlwhite))                                   $rowdata += @(,("Enable Wyse ThinOS Support",($Script:htmlsb),$GWEnableWyse,$htmlwhite))
                                $rowdata += @(,("Do not warn if server certificate is not verified",($Script:htmlsb),$SecureGatewayDisableWyseCertWarn,$htmlwhite))                                   $rowdata += @(,("Do not warn if server certificate is not verified",($Script:htmlsb),$GWDisableWyseCertWarn,$htmlwhite))
 
                        If($SecureGateway.InheritDefaultSecuritySettings) <>                         If($GW.InheritDefaultSecuritySettings)
 
                                $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null <>                                 $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
 
                                If($? -and $Null -ne $SecureGatewayDefaults) <>                                 If($? -and $Null -ne $GWDefaults)
 
                                        If($SecureGatewayDefaults.SecurityMode -eq "AllowAllExcept") <>                                         If($GWDefaults.SecurityMode -eq "AllowAllExcept")
 
                                                $SecureGatewayAllow = "AllowAllExcept" <>                                                 $GWAllow = "AllowAllExcept"
 
                                                ForEach($Item in $SecureGatewayDefaults.MACAllowExcept) <>                                                 ForEach($Item in $GWDefaults.MACAllowExcept)
 
                                                $SecureGatewayAllow = "AllowOnly" <>                                                 $GWAllow = "AllowOnly"
 
                                                ForEach($Item in $SecureGatewayDefaults.MACAllowOnly) <>                                                 ForEach($Item in $GWDefaults.MACAllowOnly)
 
                                        $SecureGatewayAllow = "AllowAllExcept" <>                                         $GWAllow = "AllowAllExcept"
 
                                If($SecureGateway.SecurityMode -eq "AllowAllExcept") <>                                 If($GW.SecurityMode -eq "AllowAllExcept")
 
                                        $SecureGatewayAllow = "AllowAllExcept" <>                                         $GWAllow = "AllowAllExcept"
 
                                        ForEach($Item in $SecureGateway.MACAllowExcept) <>                                         ForEach($Item in $GW.MACAllowExcept)
 
                                        $SecureGatewayAllow = "AllowOnly" <>                                         $GWAllow = "AllowOnly"
 
                                        ForEach($Item in $SecureGateway.MACAllowOnly) <>                                         ForEach($Item in $GW.MACAllowOnly)
 
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultSecuritySettings.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultSecuritySettings.ToString(); }) > $Null
                                If($SecureGatewayAllow -eq "AllowAllExcept")                                   If($GWAllow -eq "AllowAllExcept")
 
                                Line 3 "Inherit default settings`t`t: " $SecureGateway.InheritDefaultSecuritySettings.ToString() <>                                 Line 3 "Inherit default settings`t`t: " $GW.InheritDefaultSecuritySettings.ToString()
                                If($SecureGatewayAllow -eq "AllowAllExcept")                                   If($GWAllow -eq "AllowAllExcept")
 
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultSecuritySettings.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultSecuritySettings.ToString(),$htmlwhite)
                                If($SecureGatewayAllow -eq "AllowAllExcept")                                   If($GWAllow -eq "AllowAllExcept")
 
                        If($SecureGateway.InheritDefaultWebSettings) <>                         If($GW.InheritDefaultWebSettings)
 
                                $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null <>                                 $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
 
                                If($? -and $Null -ne $SecureGatewayDefaults) <>                                 If($? -and $Null -ne $GWDefaults)
 
                                        $SecureGatewayDefaultURL = $SecureGatewayDefaults.WebRequestsURL <>                                         $GWDefaultURL = $GWDefaults.WebRequestsURL
                                        $SecureGatewayWebCookie = $SecureGatewayDefaults.WebCookie                                           $GWWebCookie = $GWDefaults.WebCookie
 
                                        $SecureGatewayDefaultURL = "https://%hostname%/RASHTML5Gateway" <>                                         $GWDefaultURL = "https://%hostname%/RASHTML5Gateway"
                                        $SecureGatewayWebCookie = "ASP.NET_SessionId"                                           $GWWebCookie = "ASP.NET_SessionId"
 
                                $SecureGatewayDefaultURL = $SecureGateway.WebRequestsURL <>                                 $GWDefaultURL = $GW.WebRequestsURL
                                $SecureGatewayWebCookie = $SecureGateway.WebCookie                                   $GWWebCookie = $GW.WebCookie
 
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultWebSettings.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultWebSettings.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Default URL"; Value = $SecureGatewayDefaultURL; }) > $Null                                   $ScriptInformation.Add(@{Data = "Default URL"; Value = $GWDefaultURL; }) > $Null
                                $ScriptInformation.Add(@{Data = "Web cookie"; Value = $SecureGatewayWebCookie; }) > $Null                                   $ScriptInformation.Add(@{Data = "Web cookie"; Value = $GWWebCookie; }) > $Null
                                $ScriptInformation.Add(@{Data = "Use a secure web cookie"; Value = $SecureGateway.UseSecureWebCookie.ToString(); }) > $Null    
 
                                Line 3 "Inherit default settings`t`t: " $SecureGateway.InheritDefaultWebSettings.ToString() <>                                 Line 3 "Inherit default settings`t`t: " $GW.InheritDefaultWebSettings.ToString()
                                Line 3 "Default URL`t`t`t`t: " $SecureGatewayDefaultURL                                   Line 3 "Default URL`t`t`t`t: " $GWDefaultURL
                                Line 3 "Web cookie`t`t`t`t: " $SecureGatewayWebCookie                                   Line 3 "Web cookie`t`t`t`t: " $GWWebCookie
                                Line 3 "Use a secure web cookie`t`t`t: " $SecureGateway.UseSecureWebCookie.ToString()    
 
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultWebSettings.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultWebSettings.ToString(),$htmlwhite)
                                $rowdata += @(,("Default URL",($Script:htmlsb),$SecureGatewayDefaultURL,$htmlwhite))                                   $rowdata += @(,("Default URL",($Script:htmlsb),$GWDefaultURL,$htmlwhite))
                                $rowdata += @(,("Web cookie",($Script:htmlsb),$SecureGatewayWebCookie,$htmlwhite))                                   $rowdata += @(,("Web cookie",($Script:htmlsb),$GWWebCookie,$htmlwhite))
                                $rowdata += @(,("Use a secure web cookie",($Script:htmlsb),$SecureGateway.UseSecureWebCookie.ToString(),$htmlwhite))    
 
        If($MSWord -or $PDF) <>  
        {    
                WriteWordLine 2 0 "Connection Brokers"    
        }    
        If($Text)    
        {    
                Line 1 "Connection Brokers"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Connection Brokers"    
        }    
     
        Write-Verbose "$(Get-Date -Format G): Output Connection Brokers"    
        $ConnectionBrokers = Get-RASBroker -Siteid $Site.Id -EA 0 4> $Null           $PAs = Get-RASPA -Siteid $Site.Id -EA 0 4> $Null
 
                Unable to retrieve Connection Brokers for Site $($Site.Name)` <>                 Unable to retrieve Publishing Agents for Site $($Site.Name)`
 
                        WriteWordLine 0 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)" <>                         WriteWordLine 0 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)"
 
                        Line 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)" <>                         Line 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)"
 
        ElseIf($? -and $Null -eq $ConnectionBrokers) <>         ElseIf($? -and $Null -eq $PAs)
 
        No Connection Brokers retrieved for Site $($Site.Name).` <>                 No Publishing Agents retrieved for Site $($Site.Name).`
 
                        WriteWordLine 0 0 "No Connection Brokers retrieved for Site $($Site.Name)" <>                         WriteWordLine 0 0 "No Publishing Agents retrieved for Site $($Site.Name)"
 
                        Line 0 "No Connection Brokers retrieved for Site $($Site.Name)" <>                         Line 0 "No Publishing Agents retrieved for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "No Connection Brokers retrieved for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "No Publishing Agents retrieved for Site $($Site.Name)"
 
                ForEach($ConnectionBroker in $ConnectionBrokers) <>                 If($MSWord -or $PDF)
 
  <>                         WriteWordLine 2 0 "Publishing Agents"
                    }
                    If($Text)
                    {
                            Line 1 "Publishing Agents"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "Publishing Agents"
                    }
     
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Publishing Agents"
                    ForEach($PA in $PAs)
                    {
                        $ConnectionBrokerStatus = Get-RASBrokerStatus -Id $ConnectionBroker.Id -EA 0 4>$Null                           $PAStatus = Get-RASPAStatus -Id $PA.Id -EA 0 4>$Null
 
                                Unable to retrieve Status for Connection Broker $($ConnectionBroker.Id)` <>                                 Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)`
 
                                        WriteWordLine 0 0 "Unable to retrieve Status for Connection Broker $($ConnectionBroker.Id)" <>                                         WriteWordLine 0 0 "Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)"
 
                                        Line 0 "Unable to retrieve Status for Connection Broker $($ConnectionBroker.Id)" <>                                         Line 0 "Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)"
 
                                        WriteHTMLLine 0 0 "Unable to retrieve Status for Connection Broker $($ConnectionBroker.Id)" <>                                         WriteHTMLLine 0 0 "Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)"
 
                        ElseIf($? -and $Null -eq $ConnectionBrokerStatus) <>                         ElseIf($? -and $Null -eq $PAStatus)
 
                                No Status retrieved for Connection Broker $($ConnectionBroker.Id)` <>                                 No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)`
 
                                        WriteWordLine 0 0 "No Status retrieved for Connection Broker $($ConnectionBroker.Id)" <>                                         WriteWordLine 0 0 "No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)"
 
                                        Line 0 "No Status retrieved for Connection Broker $($ConnectionBroker.Id)" <>                                         Line 0 "No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)"
 
                                        WriteHTMLLine 0 0 "No Status retrieved for Connection Broker $($ConnectionBroker.Id)" <>                                         WriteHTMLLine 0 0 "No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)"
 
                                If($ConnectionBroker.Standby -eq $False) <>                                 If($PA.Standby -eq $False)
 
                                        $ConnectionBrokerPriority = "Master" <>                                         $PAPriority = "Master"
 
                                        $ConnectionBrokerPriority = "Standby" <>                                         $PAPriority = "Standby"
 
                                $ConnectionBrokerStatusAgentState = GetRASStatus $ConnectionBrokerStatus.AgentState <>                                 $PAStatusAgentState = GetRASStatus $PAStatus.AgentState
 
                                        WriteWordLine 3 0 "Connection Broker $($ConnectionBroker.Server)" <>                                         WriteWordLine 3 0 "Publishing Agents $($PA.Server)"
 
                                        $ScriptInformation.Add(@{Data = "Server"; Value = $ConnectionBroker.Server; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Server"; Value = $PA.Server; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Enabled"; Value = $ConnectionBroker.Enabled.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Priority"; Value = $ConnectionBrokerPriority; }) > $Null                                           $ScriptInformation.Add(@{Data = "Priority"; Value = $PAPriority; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $ConnectionBrokerStatusAgentState; }) > $Null                                           $ScriptInformation.Add(@{Data = "Status"; Value = $PAStatusAgentState; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Log level"; Value = $ConnectionBrokerStatus.LogLevel; }) > $Null                                           $ScriptInformation.Add(@{Data = "Log level"; Value = $PAStatus.LogLevel; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $ConnectionBroker.AdminLastMod; }) > $Null                                           $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PA.AdminLastMod; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $ConnectionBroker.TimeLastMod.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Modified on"; Value = $PA.TimeLastMod.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $ConnectionBroker.AdminCreate; }) > $Null                                           $ScriptInformation.Add(@{Data = "Created by"; Value = $PA.AdminCreate; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $ConnectionBroker.TimeCreate.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Created on"; Value = $PA.TimeCreate.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "ID"; Value = $ConnectionBroker.Id.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "ID"; Value = $PA.Id.ToString(); }) > $Null
 
                                        Line 2 "Connection Broker $($ConnectionBroker.Server)" <>                                         Line 2 "Publishing Agents $($PA.Server)"
                                        Line 3 "Server`t`t`t: " $ConnectionBroker.Server                                           Line 3 "Server`t`t`t: " $PA.Server
                                        Line 3 "Enabled`t`t`t: " $ConnectionBroker.Enabled.ToString()    
                                        Line 3 "Priority`t`t: " $ConnectionBrokerPriority                                           Line 3 "Priority`t`t: " $PAPriority
                                        Line 3 "Status`t`t`t: " $ConnectionBrokerStatusAgentState                                           Line 3 "Status`t`t`t: " $PAStatusAgentState
                                        Line 3 "Log level`t`t: " $ConnectionBrokerStatus.LogLevel                                           Line 3 "Log level`t`t: " $PAStatus.LogLevel
                                        Line 3 "Last modification by`t: " $ConnectionBroker.AdminLastMod                                           Line 3 "Last modification by`t: " $PA.AdminLastMod
                                        Line 3 "Modified on`t`t: " $ConnectionBroker.TimeLastMod.ToString()                                           Line 3 "Modified on`t`t: " $PA.TimeLastMod.ToString()
                                        Line 3 "Created by`t`t: " $ConnectionBroker.AdminCreate                                           Line 3 "Created by`t`t: " $PA.AdminCreate
                                        Line 3 "Created on`t`t: " $ConnectionBroker.TimeCreate.ToString()                                           Line 3 "Created on`t`t: " $PA.TimeCreate.ToString()
                                        Line 3 "ID`t`t`t: " $ConnectionBroker.Id.ToString()                                           Line 3 "ID`t`t`t: " $PA.Id.ToString()
 
                                        WriteHTMLLine 3 0 "Connection Broker $($ConnectionBroker.Server)" <>                                         WriteHTMLLine 3 0 "Publishing Agents $($PA.Server)"
 
                                        $columnHeaders = @("Server",($Script:htmlsb),$ConnectionBroker.Server,$htmlwhite) <>                                         $columnHeaders = @("Server",($Script:htmlsb),$PA.Server,$htmlwhite)
                                        $rowdata += @(,("Enabled",($Script:htmlsb),$ConnectionBroker.Enabled.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Priority",($Script:htmlsb),$ConnectionBrokerPriority,$htmlwhite))                                           $rowdata += @(,("Priority",($Script:htmlsb),$PAPriority,$htmlwhite))
                                        $rowdata += @(,("Status",($Script:htmlsb),$ConnectionBrokerStatusAgentState,$htmlwhite))                                           $rowdata += @(,("Status",($Script:htmlsb),$PAStatusAgentState,$htmlwhite))
                                        $rowdata += @(,("Log level",($Script:htmlsb),$ConnectionBrokerStatus.LogLevel,$htmlwhite))                                           $rowdata += @(,("Log level",($Script:htmlsb),$PAStatus.LogLevel,$htmlwhite))
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $ConnectionBroker.AdminLastMod,$htmlwhite))                                           $rowdata += @(,("Last modification by",($Script:htmlsb), $PA.AdminLastMod,$htmlwhite))
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $ConnectionBroker.TimeLastMod.ToString(),$htmlwhite))                                           $rowdata += @(,("Modified on",($Script:htmlsb), $PA.TimeLastMod.ToString(),$htmlwhite))
                                        $rowdata += @(,("Created by",($Script:htmlsb), $ConnectionBroker.AdminCreate,$htmlwhite))                                           $rowdata += @(,("Created by",($Script:htmlsb), $PA.AdminCreate,$htmlwhite))
                                        $rowdata += @(,("Created on",($Script:htmlsb), $ConnectionBroker.TimeCreate.ToString(),$htmlwhite))                                           $rowdata += @(,("Created on",($Script:htmlsb), $PA.TimeCreate.ToString(),$htmlwhite))
                                        $rowdata += @(,("ID",($Script:htmlsb),$ConnectionBroker.Id.ToString(),$htmlwhite))                                           $rowdata += @(,("ID",($Script:htmlsb),$PA.Id.ToString(),$htmlwhite))
 
                                $ScriptInformation.Add(@{Data = "Enable Server in Site"; Value = $ConnectionBroker.Enabled.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Enable Server in Site"; Value = $PA.Enabled.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Server"; Value = $ConnectionBroker.Server; }) > $Null                                   $ScriptInformation.Add(@{Data = "Server"; Value = $PA.Server; }) > $Null
                                $ScriptInformation.Add(@{Data = "IP"; Value = $ConnectionBroker.IP; }) > $Null                                   $ScriptInformation.Add(@{Data = "IP"; Value = $PA.IP; }) > $Null
                                $ScriptInformation.Add(@{Data = "Alternative IPs"; Value = $ConnectionBroker.AlternativeIPs; }) > $Null                                   $ScriptInformation.Add(@{Data = "Alternative IPs"; Value = $PA.AlternativeIPs; }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $ConnectionBroker.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $PA.Description; }) > $Null
                                $ScriptInformation.Add(@{Data = "Standby"; Value = $ConnectionBroker.Standby.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Standby"; Value = $PA.Standby.ToString(); }) > $Null
 
                                Line 3 "Enable Server in Site`t: " $ConnectionBroker.Enabled.ToString() <>                                 Line 3 "Enable Server in Site`t: " $PA.Enabled.ToString()
                                Line 3 "Server`t`t`t: " $ConnectionBroker.Server                                   Line 3 "Server`t`t`t: " $PA.Server
                                Line 3 "IP`t`t`t: " $ConnectionBroker.IP                                   Line 3 "IP`t`t`t: " $PA.IP
                                Line 3 "Alternative IPs`t`t: " $ConnectionBroker.AlternativeIPs                                   Line 3 "Alternative IPs`t`t: " $PA.AlternativeIPs
                                Line 3 "Description`t`t: " $ConnectionBroker.Description                                   Line 3 "Description`t`t: " $PA.Description
                                Line 3 "Standby`t`t`t: " $ConnectionBroker.Standby.ToString()                                   Line 3 "Standby`t`t`t: " $PA.Standby.ToString()
 
                                $columnHeaders = @("Enable Server in Site",($Script:htmlsb),$ConnectionBroker.Enabled.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Enable Server in Site",($Script:htmlsb),$PA.Enabled.ToString(),$htmlwhite)
                                $rowdata += @(,("Server",($Script:htmlsb),$ConnectionBroker.Server,$htmlwhite))                                   $rowdata += @(,("Server",($Script:htmlsb),$PA.Server,$htmlwhite))
                                $rowdata += @(,("IP",($Script:htmlsb),$ConnectionBroker.IP,$htmlwhite))                                   $rowdata += @(,("IP",($Script:htmlsb),$PA.IP,$htmlwhite))
                                $rowdata += @(,("Alternative IPs",($Script:htmlsb),$ConnectionBroker.AlternativeIPs,$htmlwhite))                                   $rowdata += @(,("Alternative IPs",($Script:htmlsb),$PA.AlternativeIPs,$htmlwhite))
                                $rowdata += @(,("Description",($Script:htmlsb),$ConnectionBroker.Description,$htmlwhite))                                   $rowdata += @(,("Description",($Script:htmlsb),$PA.Description,$htmlwhite))
                                $rowdata += @(,("Standby",($Script:htmlsb),$ConnectionBroker.Standby.ToString(),$htmlwhite))                                   $rowdata += @(,("Standby",($Script:htmlsb),$PA.Standby.ToString(),$htmlwhite))
     
                                $msg = "Properties"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Auto-promotion    
                        $ConnectionBrokerAutoPromotion = Get-RASBrokerAutoPromotionSettings -SiteId $Site.Id -EA 0 4>$Null    
                            
                        If(!$?)    
                        {    
                                Write-Warning "    
                                `n    
                                Unable to retrieve Auto-promotion for Site $($Site.Id) for Site $($Site.Id)`    
                                "    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "Unable to retrieve Auto-promotion for Site $($Site.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "Unable to retrieve Auto-promotion for Site $($Site.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "Unable to retrieve Auto-promotion for Site $($Site.Id)"    
                                }    
                        }    
                        ElseIf($? -and $Null -eq $ConnectionBrokerStatus)    
                        {    
                                Write-Host "    
                                No data retrieved for Auto-promotion for Site $($Site.Id)`    
                                " -ForegroundColor White    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "No data retrieved for Auto-promotion for Site $($Site.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "No data retrieved for Auto-promotion for Site $($Site.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "No data retrieved for Auto-promotion for Site $($Site.Id)"    
                                }    
                        }    
                        Else    
                        {    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 3 0 "Auto-promotion"    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Auto-promotion Enabled"; Value = $ConnectionBrokerAutoPromotion.Enabled.ToString(); }) > $Null    
                                        If($ConnectionBrokerAutoPromotion.Enabled)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Enable auto-promotion after (minutes)"; Value = $ConnectionBrokerAutoPromotion.AutoPromoteAfterMins.ToString(); }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Enable fallback"; Value = $ConnectionBrokerAutoPromotion.FailbackEnabled.ToString(); }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Replicate settings"; Value = $ConnectionBrokerAutoPromotion.Replicate.ToString(); }) > $Null    
                                        }    
                                            
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Auto-promotion"    
                                        Line 3 "Auto-promotion Enabled: " $ConnectionBrokerAutoPromotion.Enabled.ToString()    
                                        If($ConnectionBrokerAutoPromotion.Enabled)    
                                        {    
                                                Line 3 "Enable auto-promotion after (minutes): " $ConnectionBrokerAutoPromotion.AutoPromoteAfterMins.ToString()    
                                                Line 3 "Enable fallback: " $ConnectionBrokerAutoPromotion.FailbackEnabled.ToString()    
                                                Line 3 "Replicate settings: " $ConnectionBrokerAutoPromotion.Replicate.ToString()    
                                        }    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 3 0 "Auto-promotion"    
                                        $rowdata = @()    
                                        $columnHeaders = @("Auto-promotion Enabled",($Script:htmlsb),$ConnectionBrokerAutoPromotion.Enabled.ToString(),$htmlwhite)    
                                        If($ConnectionBrokerAutoPromotion.Enabled)    
                                        {    
                                                $rowdata += @(,("Enable auto-promotion after (minutes)",($Script:htmlsb),$ConnectionBrokerAutoPromotion.AutoPromoteAfterMins.ToString(),$htmlwhite))    
                                                $rowdata += @(,("Enable fallback",($Script:htmlsb),$ConnectionBrokerAutoPromotion.FailbackEnabled.ToString(),$htmlwhite))    
                                                $rowdata += @(,("Replicate settings",($Script:htmlsb),$ConnectionBrokerAutoPromotion.Replicate.ToString(),$htmlwhite))    
                                        }    
                                        $msg = ""    
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                        }    
                }    
        }    
            
        #Enrollment Servers    
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 2 0 "Enrollment Servers"    
        }    
        If($Text)    
        {    
                Line 1 "Enrollment Servers"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Enrollment Servers"    
        }    
     
        Write-Verbose "$(Get-Date -Format G): Output Enrollment Servers"    
        $EnrollmentServers = Get-RASEnrollmentServer -Siteid $Site.Id -EA 0 4> $Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Enrollment Servers for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Enrollment Servers for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Enrollment Servers for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve Enrollment Servers for Site $($Site.Name)"    
                }    
        }    
        ElseIf($? -and $Null -eq $EnrollmentServers)    
        {    
                Write-Host "    
        No Enrollment Servers retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Enrollment Servers retrieved for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "No Enrollment Servers retrieved for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Enrollment Servers retrieved for Site $($Site.Name)"    
                }    
        }    
        Else    
        {    
                ForEach($EnrollmentServer in $EnrollmentServers)    
                {    
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 3 0 "Enrollment Server $($EnrollmentServer.Server)"    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $EnrollmentServer.Server; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enabled"; Value = $EnrollmentServer.Enabled.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Status"; Value = "Can't find"; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $EnrollmentServer.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Log level"; Value = "Can't find"; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $EnrollmentServer.AdminLastMod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $EnrollmentServer.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $EnrollmentServer.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $EnrollmentServer.TimeCreate.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "ID"; Value = $EnrollmentServer.Id.ToString(); }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Enrollment Server $($EnrollmentServer.Server)"    
                                Line 3 "Name`t`t`t: " $EnrollmentServer.Server    
                                Line 3 "Enabled`t`t`t: " $EnrollmentServer.Enabled.ToString()    
                                Line 3 "Status`t`t`t: " "Can't find"    
                                Line 3 "Description`t`t: " $EnrollmentServer.Description    
                                Line 3 "Log level`t`t: " "Can't find"    
                                Line 3 "Last modification by`t: " $EnrollmentServer.AdminLastMod    
                                Line 3 "Modified on`t`t: " $EnrollmentServer.TimeLastMod.ToString()    
                                Line 3 "Created by`t`t: " $EnrollmentServer.AdminCreate    
                                Line 3 "Created on`t`t: " $EnrollmentServer.TimeCreate.ToString()    
                                Line 3 "ID`t`t`t: " $EnrollmentServer.Id.ToString()    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 3 0 "Enrollment Server $($EnrollmentServer.Server)"    
                                $rowdata = @()    
                                $columnHeaders = @("Name",($Script:htmlsb),$EnrollmentServer.Server,$htmlwhite)    
                                $rowdata += @(,("Enabled",($Script:htmlsb),$EnrollmentServer.Enabled.ToString(),$htmlwhite))    
                                $rowdata += @(,("Status",($Script:htmlsb),"Can't find",$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$EnrollmentServer.Description,$htmlwhite))    
                                $rowdata += @(,("Log level",($Script:htmlsb),"Can't find",$htmlwhite))    
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $EnrollmentServer.AdminLastMod,$htmlwhite))    
                                $rowdata += @(,("Modified on",($Script:htmlsb), $EnrollmentServer.TimeLastMod.ToString(),$htmlwhite))    
                                $rowdata += @(,("Created by",($Script:htmlsb), $EnrollmentServer.AdminCreate,$htmlwhite))    
                                $rowdata += @(,("Created on",($Script:htmlsb), $EnrollmentServer.TimeCreate.ToString(),$htmlwhite))    
                                $rowdata += @(,("ID",($Script:htmlsb),$EnrollmentServer.Id.ToString(),$htmlwhite))    
     
                                $msg = ""    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Properties"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Properties"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($EnrollmentServer.PreferredBrokerId -eq 0)    
                        {    
                                $EnrollmentServerPreferredConnectionBroker = "Automatic"    
                        }    
                        Else    
                        {    
                                $EnrollmentServerPreferredConnectionBroker = (Get-RASBroker -Id $EnrollmentServer.PreferredBrokerId -EA 0 4>$Null).Server    
                        }    
     
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Enable Enrollment Server"; Value = $EnrollmentServer.Enabled.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Server"; Value = $EnrollmentServer.Server; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $EnrollmentServer.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $EnrollmentServerPreferredConnectionBroker; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Enable Enrollment Server`t: " $EnrollmentServer.Enabled.ToString()    
                                Line 3 "Server`t`t`t`t: " $EnrollmentServer.Server    
                                Line 3 "Description`t`t`t: " $EnrollmentServer.Description    
                                Line 3 "Preferred Connection Broker`t: " $EnrollmentServerPreferredConnectionBroker    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Enable Enrollment Server",($Script:htmlsb),$EnrollmentServer.Enabled.ToString(),$htmlwhite)    
                                $rowdata += @(,("Server",($Script:htmlsb),$EnrollmentServer.Server,$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$EnrollmentServer.Description,$htmlwhite))    
                                $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$EnrollmentServerPreferredConnectionBroker,$htmlwhite))    
 
  -+         #Enrollment Servers - not in PoSH
            
 
        If($MSWord -or $PDF) <>         If([version]$Script:RASVersion -ge [version]"18.3")
 
                WriteWordLine 2 0 "HALB" <>  
        }    
        If($Text)    
        {    
                Line 1 "HALB"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "HALB"    
        }    
     
        Write-Verbose "$(Get-Date -Format G): Output HALB"    
        $HALBs = Get-RASHALB -Siteid $Site.Id -EA 0 4> $Null                    $HALBs = Get-RASHALB -Siteid $Site.Id -EA 0 4> $Null 
 
        If(!$?) <>                 If(!$?)
        {                   {
                Write-Warning "                           Write-Warning "
                `n                           `n
                Unable to retrieve HALBs for Site $($Site.Name)`                           Unable to retrieve HALBs for Site $($Site.Name)`
                "                           "
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve HALBs for Site $($Site.Name)"                                   WriteWordLine 0 0 "Unable to retrieve HALBs for Site $($Site.Name)"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "Unable to retrieve HALBs for Site $($Site.Name)"                                   Line 0 "Unable to retrieve HALBs for Site $($Site.Name)"
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve HALBs for Site $($Site.Name)"                                   WriteHTMLLine 0 0 "Unable to retrieve HALBs for Site $($Site.Name)"
                }                           }
        }                   }
        ElseIf($? -and $Null -eq $HALBs)                   ElseIf($? -and $Null -eq $HALBs)
        {                   {
                Write-Host "                           Write-Host "
        No HALBs retrieved for Site $($Site.Name).`                           No HALBs retrieved for Site $($Site.Name).`
                " -ForegroundColor White                           " -ForegroundColor White
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "No HALBs retrieved for Site $($Site.Name)"                                   WriteWordLine 0 0 "No HALBs retrieved for Site $($Site.Name)"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "No HALBs retrieved for Site $($Site.Name)"                                   Line 0 "No HALBs retrieved for Site $($Site.Name)"
                        Line 0 ""    
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "No HALBs retrieved for Site $($Site.Name)"                                   WriteHTMLLine 0 0 "No HALBs retrieved for Site $($Site.Name)"
                }                           }
        }                   }
        Else                   Else
        {                   {
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 2 0 "HALB"
                            }
                            If($Text)
                            {
                                    Line 1 "HALB"
                            }
                            If($HTML)
                            {
                                    WriteHTMLLine 2 0 "HALB"
                            }
     
                Write-Verbose "$(Get-Date -Format G): `tOutput Virtual Servers"                           Write-Verbose "$(Get-Date -Format G): `t`tOutput HALB"
                ForEach($HALB in $HALBs)                           ForEach($HALB in $HALBs)
                {                           {
                        $HALBStatusResult = Get-RASHALBStatus -Name $HALB.Name -EA 0 4> $Null                                    $HALBStatusResult = Get-RASHALBStatus -Name $HALB.Name -EA 0 4> $Null 
                                                          
                        If($? -and $Null -ne $HALBStatusResult)                                   If($? -and $Null -ne $HALBStatusResult)
                        {                                   {
                                $HALBStatus = GetRASStatus $HALBStatusResult.AgentState                                           $HALBStatus = GetRASStatus $HALBStatusResult.AgentState
                        }                                   }
                        Else                                   Else
                        {                                   {
                                $HALBStatus = "Unable to determine HALB status"                                           $HALBStatus = "Unable to determine HALB status"
                        }                                   }
                                                          
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                WriteWordLine 3 0 "HALB $($HALB.Name)"                                           WriteWordLine 3 0 "HALB $($HALB.Name)"
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                $ScriptInformation.Add(@{Data = "Name"; Value = $HALB.Name; }) > $Null                                           $ScriptInformation.Add(@{Data = "Name"; Value = $HALB.Name; }) > $Null
                                $ScriptInformation.Add(@{Data = "IPv4"; Value = $HALB.VirtualIPV4; }) > $Null                                           $ScriptInformation.Add(@{Data = "IPv4"; Value = $HALB.VirtualIPV4; }) > $Null
                                $ScriptInformation.Add(@{Data = "IPv6"; Value = $HALB.VirtualIPV6; }) > $Null                                           $ScriptInformation.Add(@{Data = "IPv6"; Value = $HALB.VirtualIPV6; }) > $Null
                                $ScriptInformation.Add(@{Data = "Status"; Value = $HALBStatus; }) > $Null                                           $ScriptInformation.Add(@{Data = "Status"; Value = $HALBStatus; }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $HALB.Description; }) > $Null                                           $ScriptInformation.Add(@{Data = "Description"; Value = $HALB.Description; }) > $Null
                                $ScriptInformation.Add(@{Data = "Public Address"; Value = $HALB.PublicAddress; }) > $Null                                           $ScriptInformation.Add(@{Data = "Public Address"; Value = $HALB.PublicAddress; }) > $Null
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $HALB.AdminLastMod; }) > $Null                                           $ScriptInformation.Add(@{Data = "Last modification by"; Value = $HALB.AdminLastMod; }) > $Null
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $HALB.TimeLastMod.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Modified on"; Value = $HALB.TimeLastMod.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $HALB.AdminCreate; }) > $Null                                           $ScriptInformation.Add(@{Data = "Created by"; Value = $HALB.AdminCreate; }) > $Null
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $HALB.TimeCreate.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Created on"; Value = $HALB.TimeCreate.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "ID"; Value = $HALB.Id.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "ID"; Value = $HALB.Id.ToString(); }) > $Null
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 2 "HALB $($HALB.Name)"                                           Line 2 "HALB $($HALB.Name)"
                                Line 3 "Name`t`t`t: " $HALB.Name                                           Line 3 "Name`t`t`t: " $HALB.Name
                                Line 3 "IPv4`t`t`t: " $HALB.VirtualIPV4                                           Line 3 "IPv4`t`t`t: " $HALB.VirtualIPV4
                                Line 3 "IPv6`t`t`t: " $HALB.VirtualIPV6                                           Line 3 "IPv6`t`t`t: " $HALB.VirtualIPV6
                                Line 3 "Status`t`t`t: " $HALBStatus                                           Line 3 "Status`t`t`t: " $HALBStatus
                                Line 3 "Description`t`t: " $HALB.Description                                           Line 3 "Description`t`t: " $HALB.Description
                                Line 3 "Public Address`t`t: " $HALB.PublicAddress                                           Line 3 "Public Address`t`t: " $HALB.PublicAddress
                                Line 3 "Last modification by`t: " $HALB.AdminLastMod                                           Line 3 "Last modification by`t: " $HALB.AdminLastMod
                                Line 3 "Modified on`t`t: " $HALB.TimeLastMod.ToString()                                           Line 3 "Modified on`t`t: " $HALB.TimeLastMod.ToString()
                                Line 3 "Created by`t`t: " $HALB.AdminCreate                                           Line 3 "Created by`t`t: " $HALB.AdminCreate
                                Line 3 "Created on`t`t: " $HALB.TimeCreate.ToString()                                           Line 3 "Created on`t`t: " $HALB.TimeCreate.ToString()
                                Line 3 "ID`t`t`t: " $HALB.Id.ToString()                                           Line 3 "ID`t`t`t: " $HALB.Id.ToString()
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                WriteHTMLLine 3 0 "HALB $($HALB.Name)"                                           WriteHTMLLine 3 0 "HALB $($HALB.Name)"
                                $rowdata = @()                                           $rowdata = @()
                                $columnHeaders = @("Name",($Script:htmlsb),$HALB.Name,$htmlwhite)                                           $columnHeaders = @("Name",($Script:htmlsb),$HALB.Name,$htmlwhite)
                                $rowdata += @(,("IPv4",($Script:htmlsb),$HALB.VirtualIPV4,$htmlwhite))                                           $rowdata += @(,("IPv4",($Script:htmlsb),$HALB.VirtualIPV4,$htmlwhite))
                                $rowdata += @(,("IPv6",($Script:htmlsb),$HALB.VirtualIPV6,$htmlwhite))                                           $rowdata += @(,("IPv6",($Script:htmlsb),$HALB.VirtualIPV6,$htmlwhite))
                                $rowdata += @(,("Status",($Script:htmlsb),$HALBStatus,$htmlwhite))                                           $rowdata += @(,("Status",($Script:htmlsb),$HALBStatus,$htmlwhite))
                                $rowdata += @(,("Description",($Script:htmlsb),$HALB.Description,$htmlwhite))                                           $rowdata += @(,("Description",($Script:htmlsb),$HALB.Description,$htmlwhite))
                                $rowdata += @(,("Public Address",($Script:htmlsb),$HALB.PublicAddress,$htmlwhite))                                           $rowdata += @(,("Public Address",($Script:htmlsb),$HALB.PublicAddress,$htmlwhite))
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $HALB.AdminLastMod,$htmlwhite))                                           $rowdata += @(,("Last modification by",($Script:htmlsb), $HALB.AdminLastMod,$htmlwhite))
                                $rowdata += @(,("Modified on",($Script:htmlsb), $HALB.TimeLastMod.ToString(),$htmlwhite))                                           $rowdata += @(,("Modified on",($Script:htmlsb), $HALB.TimeLastMod.ToString(),$htmlwhite))
                                $rowdata += @(,("Created by",($Script:htmlsb), $HALB.AdminCreate,$htmlwhite))                                           $rowdata += @(,("Created by",($Script:htmlsb), $HALB.AdminCreate,$htmlwhite))
                                $rowdata += @(,("Created on",($Script:htmlsb), $HALB.TimeCreate.ToString(),$htmlwhite))                                           $rowdata += @(,("Created on",($Script:htmlsb), $HALB.TimeCreate.ToString(),$htmlwhite))
                                $rowdata += @(,("ID",($Script:htmlsb),$HALB.Id.ToString(),$htmlwhite))                                           $rowdata += @(,("ID",($Script:htmlsb),$HALB.Id.ToString(),$htmlwhite))
 
                                $msg = "" <>                                         $msg = ""
                                $columnWidths = @("200","275")                                           $columnWidths = @("200","275")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                        }                                   }
 
                        If($MSWord -or $PDF) <>                                 If($MSWord -or $PDF)
                        {                                   {
                                WriteWordLine 4 0 "General"                                           WriteWordLine 4 0 "General"
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 2 "General"                                           Line 2 "General"
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                #Nothing                                           #Nothing
                        }                                   }
                                                          
                        Switch($HALB.IPVersion)                                   Switch($HALB.IPVersion)
                        {                                   {
                                "Version4"              {$HALBIPVersion = "Version 4"; Break}                                           "Version4"              {$HALBIPVersion = "Version 4"; Break}
                                "Version6"              {$HALBIPVersion = "Version 6"; Break}                                           "Version6"              {$HALBIPVersion = "Version 6"; Break}
                                "BothVersions"  {$HALBIPVersion = "Both version 4 & 6"; Break}                                           "BothVersions"  {$HALBIPVersion = "Both version 4 & 6"; Break}
                                Default                 {$HALBIPVersion = "Unable to determine IP version: $($HALB.IPVersion)"; Break}                                           Default                 {$HALBIPVersion = "Unable to determine IP version: $($HALB.IPVersion)"; Break}
                        }                                   }
                                                          
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                $ScriptInformation.Add(@{Data = "Enable HALB"; Value = $HALB.EnableHALBInstance.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Enable HALB"; Value = $HALB.EnableHALBInstance.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Name"; Value = $HALB.Name; }) > $Null                                           $ScriptInformation.Add(@{Data = "Name"; Value = $HALB.Name; }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $HALB.Description; }) > $Null                                           $ScriptInformation.Add(@{Data = "Description"; Value = $HALB.Description; }) > $Null
                                $ScriptInformation.Add(@{Data = "Public address"; Value = $HALB.PublicAddress; }) > $Null                                           $ScriptInformation.Add(@{Data = "Public address"; Value = $HALB.PublicAddress; }) > $Null
                                $ScriptInformation.Add(@{Data = "Virtual IP"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "Virtual IP"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Use IP version"; Value = $HALBIPVersion; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Use IP version"; Value = $HALBIPVersion; }) > $Null
                                $ScriptInformation.Add(@{Data = "     IPv4"; Value = $HALB.VirtualIPV4; }) > $Null                                           $ScriptInformation.Add(@{Data = "     IPv4"; Value = $HALB.VirtualIPV4; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Subnet Mask"; Value = $HALB.SubNetMask; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Subnet Mask"; Value = $HALB.SubNetMask; }) > $Null
                                $ScriptInformation.Add(@{Data = "     IPv6"; Value = $HALB.VirtualIPV6; }) > $Null                                           $ScriptInformation.Add(@{Data = "     IPv6"; Value = $HALB.VirtualIPV6; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Prefix"; Value = $HALB.PrefixIPV6; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Prefix"; Value = $HALB.PrefixIPV6; }) > $Null
                                $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "     LB Gateway Payload"; Value = $HALB.EnableGatewayPayload.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "     LB Gateway Payload"; Value = $HALB.EnableGWPayload.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "     LB SSL Payload"; Value = $HALB.EnableSSLPayload.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "     LB SSL Payload"; Value = $HALB.EnableSSLPayload.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "     Device Management"; Value = $HALB.EnableDeviceManagement.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "     Device Management"; Value = $HALB.EnableDeviceManagement.ToString(); }) > $Null
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 3 "Enable HALB`t`t`t: " $HALB.EnableHALBInstance.ToString()                                           Line 3 "Enable HALB`t`t`t: " $HALB.EnableHALBInstance.ToString()
                                Line 3 "Name`t`t`t`t: " $HALB.Name                                           Line 3 "Name`t`t`t`t: " $HALB.Name
                                Line 3 "Description`t`t`t: " $HALB.Description                                           Line 3 "Description`t`t`t: " $HALB.Description
                                Line 3 "Public address`t`t`t: " $HALB.PublicAddress                                           Line 3 "Public address`t`t`t: " $HALB.PublicAddress
                                Line 3 "Virtual IP"                                           Line 3 "Virtual IP"
                                Line 4 "Use IP version`t`t: " $HALBIPVersion                                           Line 4 "Use IP version`t`t: " $HALBIPVersion
                                Line 4 "IPv4`t`t`t: " $HALB.VirtualIPV4                                           Line 4 "IPv4`t`t`t: " $HALB.VirtualIPV4
                                Line 4 "Subnet Mask`t`t: " $HALB.SubNetMask                                           Line 4 "Subnet Mask`t`t: " $HALB.SubNetMask
                                Line 4 "IPv6`t`t`t: " $HALB.VirtualIPV6                                           Line 4 "IPv6`t`t`t: " $HALB.VirtualIPV6
                                Line 4 "Prefix`t`t`t: " $HALB.PrefixIPV6                                           Line 4 "Prefix`t`t`t: " $HALB.PrefixIPV6
                                Line 3 "Settings"                                           Line 3 "Settings"
                                Line 4 "LB Gateway Payload`t: " $HALB.EnableGatewayPayload.ToString()                                           Line 4 "LB Gateway Payload`t: " $HALB.EnableGWPayload.ToString()
                                Line 4 "LB SSL Payload`t`t: " $HALB.EnableSSLPayload.ToString()                                           Line 4 "LB SSL Payload`t`t: " $HALB.EnableSSLPayload.ToString()
                                Line 4 "Device Management`t: " $HALB.EnableDeviceManagement.ToString()                                           Line 4 "Device Management`t: " $HALB.EnableDeviceManagement.ToString()
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $rowdata = @()                                           $rowdata = @()
                                $columnHeaders = @("Enable HALB",($Script:htmlsb),$HALB.EnableHALBInstance.ToString(),$htmlwhite)                                           $columnHeaders = @("Enable HALB",($Script:htmlsb),$HALB.EnableHALBInstance.ToString(),$htmlwhite)
                                $rowdata += @(,("Name",($Script:htmlsb),$HALB.Name,$htmlwhite))                                           $rowdata += @(,("Name",($Script:htmlsb),$HALB.Name,$htmlwhite))
                                $rowdata += @(,("Description",($Script:htmlsb),$HALB.Description,$htmlwhite))                                           $rowdata += @(,("Description",($Script:htmlsb),$HALB.Description,$htmlwhite))
                                $rowdata += @(,("Public address",($Script:htmlsb),$HALB.PublicAddress,$htmlwhite))                                           $rowdata += @(,("Public address",($Script:htmlsb),$HALB.PublicAddress,$htmlwhite))
                                $rowdata += @(,("Virtual IP",($Script:htmlsb), "",$htmlwhite))                                           $rowdata += @(,("Virtual IP",($Script:htmlsb), "",$htmlwhite))
                                $rowdata += @(,("     Use IP version",($Script:htmlsb), $HALBIPVersion,$htmlwhite))                                           $rowdata += @(,("     Use IP version",($Script:htmlsb), $HALBIPVersion,$htmlwhite))
                                $rowdata += @(,("     IPv4",($Script:htmlsb), $HALB.VirtualIPV4,$htmlwhite))                                           $rowdata += @(,("     IPv4",($Script:htmlsb), $HALB.VirtualIPV4,$htmlwhite))
                                $rowdata += @(,("     Subnet Mask",($Script:htmlsb), $HALB.SubNetMask,$htmlwhite))                                           $rowdata += @(,("     Subnet Mask",($Script:htmlsb), $HALB.SubNetMask,$htmlwhite))
                                $rowdata += @(,("     IPv6",($Script:htmlsb), $HALB.VirtualIPV6,$htmlwhite))                                           $rowdata += @(,("     IPv6",($Script:htmlsb), $HALB.VirtualIPV6,$htmlwhite))
                                $rowdata += @(,("     Prefix",($Script:htmlsb), $HALB.PrefixIPV6,$htmlwhite))                                           $rowdata += @(,("     Prefix",($Script:htmlsb), $HALB.PrefixIPV6,$htmlwhite))
                                $rowdata += @(,("Settings",($Script:htmlsb), "",$htmlwhite))                                           $rowdata += @(,("Settings",($Script:htmlsb), "",$htmlwhite))
                                $rowdata += @(,("     LB Gateway Payload",($Script:htmlsb), $HALB.EnableGatewayPayload.ToString(),$htmlwhite))                                           $rowdata += @(,("     LB Gateway Payload",($Script:htmlsb), $HALB.EnableGWPayload.ToString(),$htmlwhite))
                                $rowdata += @(,("     LB SSL Payload",($Script:htmlsb), $HALB.EnableSSLPayload.ToString(),$htmlwhite))                                           $rowdata += @(,("     LB SSL Payload",($Script:htmlsb), $HALB.EnableSSLPayload.ToString(),$htmlwhite))
                                $rowdata += @(,("     Device Management",($Script:htmlsb), $HALB.EnableDeviceManagement.ToString(),$htmlwhite))                                           $rowdata += @(,("     Device Management",($Script:htmlsb), $HALB.EnableDeviceManagement.ToString(),$htmlwhite))
 
                                $msg = "General" <>                                         $msg = "General"
                                $columnWidths = @("200","400")                                           $columnWidths = @("200","400")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                        }                                   }
 
                        If($MSWord -or $PDF) <>                                 If($MSWord -or $PDF)
                        {                                   {
                                WriteWordLine 4 0 "LB gateway payload"                                           WriteWordLine 4 0 "LB gateway payload"
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 2 "LB gateway payload"                                           Line 2 "LB gateway payload"
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                WriteHTMLLine 4 0 "LB gateway payload"                                           WriteHTMLLine 4 0 "LB gateway payload"
                        }                                   }
                                                          
                        $HALBGatewayPort = $HALB.GatewayConfig.Port.ToString()                                   $HALBGatewayPort = $HALB.GatewayConfig.Port.ToString()
                        $HALBGateways    = $HALB.GatewayConfig.Gateways                                   $HALBGateways    = $HALB.GatewayConfig.Gateways
                                                          
                        #First, get the port                                   #First, get the port
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                $ScriptInformation.Add(@{Data = "Port"; Value = $HALBGatewayPort; }) > $Null                                           $ScriptInformation.Add(@{Data = "Port"; Value = $HALBGatewayPort; }) > $Null
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 3 "Port: " $HALBGatewayPort                                           Line 3 "Port: " $HALBGatewayPort
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $rowdata = @()                                           $rowdata = @()
                                $columnHeaders = @("Port",($Script:htmlsb),$HALBGatewayPort,$htmlwhite)                                           $columnHeaders = @("Port",($Script:htmlsb),$HALBGatewayPort,$htmlwhite)
                                #$rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                           #$rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
 
                                $msg = "" <>                                         $msg = ""
                                $columnWidths = @("200","400")                                           $columnWidths = @("200","400")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                        }                                   }
 
                        #second, process the gateways <>                                 #second, process the gateways
                        #do output headers                                   #do output headers
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                [System.Collections.Hashtable[]] $GatewaysWordTable = @();                                           [System.Collections.Hashtable[]] $GatewaysWordTable = @();
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 3 "Gateways                                                 Status                                  "                                           Line 3 "Gateways                                                 Status                                  "
                                Line 3 "================================================================================================="                                           Line 3 "================================================================================================="
                                #       abcdefghijklmno.abcdefghijklmno.local (999.999.999.999)SS1234567890123456789012345678901234567890                                           #       abcdefghijklmno.abcdefghijklmno.local (999.999.999.999)SS1234567890123456789012345678901234567890
                                #       1234567890123456789012345678901234567890123456789012345                                           #       1234567890123456789012345678901234567890123456789012345
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $rowdata = @()                                           $rowdata = @()
                        }                                   }
                                                          
                        #process the gateways data                                   #process the gateways data
                        ForEach($GatewayItem in $HALBGateways)                                   ForEach($GWItem in $HALBGateways)
                        {                                   {
                                $ip = $GatewayItem.Keys                                           $ip = $GWItem.Keys
                                $Results = [System.Net.Dns]::gethostentry($ip)                                           $Results = [System.Net.Dns]::gethostentry($ip)
                                $hostname = $Results.HostName                                           $hostname = $Results.HostName
                                $TempGW = Get-RASGatewayStatus -Server $hostname -EA 0 4> $Null                                           $TempGW = Get-RASGWStatus -Server $hostname -EA 0 4> $Null
                                $HALBGWStatus = GetRASStatus $TempGW.AgentState                                           $HALBGWStatus = GetRASStatus $TempGW.AgentState
                                                                          
                                If($MSWord -or $PDF)                                           If($MSWord -or $PDF)
                                {                                           {
                                        $GatewaysWordTableRowHash = @{                                                   $GatewaysWordTableRowHash = @{
                                                Gateway       = "$hostname ($ip)";                                                           Gateway       = "$hostname ($ip)";
                                                GatewayStatus = $HALBGWStatus;                                                           GatewayStatus = $HALBGWStatus;
                                        }                                                   }
                                        $GatewaysWordTable += $GatewaysWordTableRowHash                                                   $GatewaysWordTable += $GatewaysWordTableRowHash
                                }                                           }
                                If($Text)                                           If($Text)
                                {                                           {
                                        Line 3 ( "{0,-55}  {1,-40}" -f "$hostname ($ip)", $HALBGWStatus)                                                   Line 3 ( "{0,-55}  {1,-40}" -f "$hostname ($ip)", $HALBGWStatus)
                                }                                           }
                                If($HTML)                                           If($HTML)
                                {                                           {
                                        $rowdata += @(,(                                                   $rowdata += @(,(
                                        "$hostname ($ip)",$htmlwhite,                                                   "$hostname ($ip)",$htmlwhite,
                                        $HALBGWStatus,$htmlwhite))                                                   $HALBGWStatus,$htmlwhite))
                                }                                           }
                        }                                   }
                                                          
                        #output the Word/PDF and HTML tables                                   #output the Word/PDF and HTML tables
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                If($GatewaysWordTable.Count -gt 0)                                           If($GatewaysWordTable.Count -gt 0)
                                {                                           {
                                        $Table = AddWordTable -Hashtable $GatewaysWordTable `                                                   $Table = AddWordTable -Hashtable $GatewaysWordTable `
                                        -Columns  Gateway,GatewayStatus `                                                   -Columns  Gateway,GatewayStatus `
                                        -Headers  "Gateways","Status"`                                                   -Headers  "Gateways","Status"`
                                        -Format $wdTableGrid `                                                   -Format $wdTableGrid `
                                        -AutoFit $wdAutoFitFixed;                                                   -AutoFit $wdAutoFitFixed;
 
                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15; <>                                                 SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                        $Table.Columns.Item(1).Width = 200; <>                                                 $Table.Columns.Item(1).Width = 200;
                                        $Table.Columns.Item(2).Width = 250;                                                   $Table.Columns.Item(2).Width = 250;
 
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                        FindWordDocumentEnd <>                                                 FindWordDocumentEnd
                                        $Table = $Null                                                   $Table = $Null
                                        WriteWordLine 0 0 ""                                                   WriteWordLine 0 0 ""
                                }                                           }
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $columnHeaders = @(                                           $columnHeaders = @(
                                "Gateways",($Script:htmlsb),                                           "Gateways",($Script:htmlsb),
                                "Status",($Script:htmlsb))                                           "Status",($Script:htmlsb))
 
                                $msg = "" <>                                         $msg = ""
                                $columnWidths = @("200","400")                                           $columnWidths = @("200","400")
                                FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "600"                                           FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "600"
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                        }                                   }
                                                          
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                WriteWordLine 4 0 "LB SSL payload"                                           WriteWordLine 4 0 "LB SSL payload"
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 2 "LB SSL payload"                                           Line 2 "LB SSL payload"
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                #Nothing                                           #Nothing
                        }                                   }
                                                          
                        $HALBSSLGatewayPort = $HALB.SSLConfig.GatewayConfig.Port.ToString()                                   $HALBSSLGatewayPort = $HALB.SSLConfig.GatewayConfig.Port.ToString()
                        $HALBSSLGateways    = $HALB.SSLConfig.GatewayConfig.Gateways                                   $HALBSSLGateways    = $HALB.SSLConfig.GatewayConfig.Gateways
                                                          
                        Switch($HALB.SSLConfig.SSLMode)                                   Switch($HALB.SSLConfig.SSLMode)
                        {                                   {
                                "SSLOffloading"         {$HALBSSLMode = "SSL Offloading"; Break}                                           "SSLOffloading"         {$HALBSSLMode = "SSL Offloading"; Break}
                                "SSLPassthrough"        {$HALBSSLMode = "Passthrough"; Break}                                           "SSLPassthrough"        {$HALBSSLMode = "Passthrough"; Break}
                                Default                         {$HALBSSLMode = "Unable to determine SSL Mode: $($HALB.SSLConfig.SSLMode)"; Break}                                           Default                         {$HALBSSLMode = "Unable to etermine SSL Mode: $($HALB.SSLConfig.SSLMode)"; Break}
                        }                                   }
                                                          
                        If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")                                   If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")
                        {                                   {
                                Switch($HALB.SSLConfig.MinSSLVersion)                                           Switch($HALB.SSLConfig.MinSSLVersion)
                                {                                           {
                                        #"SSLv2"                {$HALBSSLAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}                                                   "SSLv2"         {$HALBSSLAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}
                                        "SSLv3"         {$HALBSSLAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}                                                   "SSLv3"         {$HALBSSLAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}
                                        "TLSv1"         {$HALBSSLAcceptedSSLVersions = "TLS v1.0 - TLS v1.2"; Break}                                                   "TLSv1"         {$HALBSSLAcceptedSSLVersions = "TLS v1.0 - TLS v1.2"; Break}
                                        "TLSv1_1"       {$HALBSSLAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}                                                   "TLSv1_1"       {$HALBSSLAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}
                                        "TLSv1_2"       {$HALBSSLAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}                                                   "TLSv1_2"       {$HALBSSLAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}
                                        Default         {$HALBSSLAcceptedSSLVersions = "Unable to determine Minimum SSL version: $($HALB.SSLConfig.MinSSLVersion)"; Break}                                                   Default         {$HALBSSLAcceptedSSLVersions = "Unable to determine Minimum SSL version: $($HALB.SSLConfig.MinSSLVersion)"; Break}
                                }                                           }
                                                                          
                                If($HALB.SSLConfig.SSLCipherStrength -eq "Custom")                                           If($HALB.SSLConfig.SSLCipherStrength -eq "Custom")
                                {                                           {
                                        $HALBSSLCipherStrength = "Custom"                                                   $HALBSSLCipherStrength = "Custom"
                                        $HALBSSLCipher         = $HALB.SSLConfig.SSLCustomCipher                                                   $HALBSSLCipher         = $HALB.SSLConfig.SSLCustomCipher
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $HALBSSLCipherStrength = $HALB.SSLConfig.SSLCipherStrength                                                   $HALBSSLCipherStrength = $HALB.SSLConfig.SSLCipherStrength
                                        Switch($HALB.SSLConfig.SSLCipherStrength)                                                   Switch($HALB.SSLConfig.SSLCipherStrength)
                                        {                                                   {
                                                "Low"           {$HALBSSLCipher = "All:!aNULL:!eNULL"; Break}                                                           "Low"           {$HALBSSLCipher = "All:!aNULL:!eNULL"; Break}
                                                "Medium"        {$HALBSSLCipher = "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM"; Break}                                                           "Medium"        {$HALBSSLCipher = "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM"; Break}
                                                "High"          {$HALBSSLCipher = "EECDH:!SSLv2:!aNULL:!RC4:!ADH:!eNULL:!LOW:!MEDIUM:!EXP:+HIGH"; Break}                                                           "High"          {$HALBSSLCipher = "EECDH:!SSLv2:!aNULL:!RC4:!ADH:!eNULL:!LOW:!MEDIUM:!EXP:+HIGH"; Break}
                                                Default         {$HALBSSLCipher = "Unable to determine SSL cipher strength: $($HALB.SSLConfig.SSLCipherStrength)"; Break}                                                           Default         {$HALBSSLCipher = "Unable to determine SSL cipher strength: $($HALB.SSLConfig.SSLCipherStrength)"; Break}
                                        }                                                   }
                                }                                           }
                                $HALBSSLUseServerPreference = $HALB.SSLConfig.SSLCipherPreference.ToString()                                           $HALBSSLUseServerPreference = $HALB.SSLConfig.SSLCipherPreference.ToString()
                                If($HALB.SSLConfig.CertID -eq 0)                                           If($HALB.SSLConfig.CertID -eq 0)
                                {                                           {
                                        $HALBSSLCertificates = "All matching usage"                                                   $HALBSSLCertificates = "All matching usage"
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $Results = Get-RASCertificate -Id $HALB.SSLConfig.CertID -EA 0 4> $Null                                                   $Results = Get-RASCertificate -Id $HALB.SSLConfig.CertID -EA 0 4> $Null
                                                                                          
                                        If($? -and $Null -ne $Results)                                                   If($? -and $Null -ne $Results)
                                        {                                                   {
                                                $HALBSSLCertificates = $Results.Name                                                           $HALBSSLCertificates = $Results.Name
                                        }                                                   }
                                        Else                                                   Else
                                        {                                                   {
                                                $HALBSSLCertificates = "Unable to find certificate with an ID of $($HALB.SSLConfig.CertID)"                                                           $HALBSSLCertificates = "Unable to find certificate with an ID of $($HALB.SSLConfig.CertID)"
                                        }                                                   }
                                }                                           }
                        }                                   }
                        Else                                   Else
                        {                                   {
                                $HALBSSLAcceptedSSLVersions = ""                                           $HALBSSLAcceptedSSLVersions = ""
                                $HALBSSLCipherStrength      = ""                                           $HALBSSLCipherStrength      = ""
                                $HALBSSLCipher              = ""                                           $HALBSSLCipher              = ""
                                $HALBSSLUseServerPreference = ""                                           $HALBSSLUseServerPreference = ""
                                $HALBSSLCertificates        = ""                                           $HALBSSLCertificates        = ""
                        }                                   }
                                                          
                        #First, get the port                                   #First, get the port
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                $ScriptInformation.Add(@{Data = "Port"; Value = $HALBSSLGatewayPort; }) > $Null                                           $ScriptInformation.Add(@{Data = "Port"; Value = $HALBSSLGatewayPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "Mode"; Value = $HALBSSLMode; }) > $Null                                           $ScriptInformation.Add(@{Data = "Mode"; Value = $HALBSSLMode; }) > $Null
                                If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")                                           If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")
                                {                                           {
                                        $ScriptInformation.Add(@{Data = "Security"; Value = ""; }) > $Null                                                   $ScriptInformation.Add(@{Data = "Security"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Accepted SSL Versions"; Value = $HALBSSLAcceptedSSLVersions; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Accepted SSL Versions"; Value = $HALBSSLAcceptedSSLVersions; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Cipher Strength"; Value = $HALBSSLCipherStrength; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Cipher Strength"; Value = $HALBSSLCipherStrength; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Cipher"; Value = $HALBSSLCipher; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Cipher"; Value = $HALBSSLCipher; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Use ciphers according to server preference"; Value = $HALBSSLUseServerPreference; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Use ciphers according to server preference"; Value = $HALBSSLUseServerPreference; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Certificates"; Value = $HALBSSLCertificates; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Certificates"; Value = $HALBSSLCertificates; }) > $Null
                                }                                           }
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 3 "Port: " $HALBSSLGatewayPort                                           Line 3 "Port: " $HALBSSLGatewayPort
                                Line 3 "Mode: " $HALBSSLMode                                           Line 3 "Mode: " $HALBSSLMode
                                If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")                                           If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")
                                {                                           {
                                        Line 3 "Security"                                                   Line 3 "Security"
                                        Line 4 "Accepted SSL Versions`t`t`t`t: " $HALBSSLAcceptedSSLVersions                                                   Line 4 "Accepted SSL Versions`t`t`t`t: " $HALBSSLAcceptedSSLVersions
                                        Line 4 "Cipher Strength`t`t`t`t`t: " $HALBSSLCipherStrength                                                   Line 4 "Cipher Strength`t`t`t`t`t: " $HALBSSLCipherStrength
                                        Line 4 "Cipher`t`t`t`t`t`t: " $HALBSSLCipher                                                   Line 4 "Cipher`t`t`t`t`t`t: " $HALBSSLCipher
                                        Line 4 "Use ciphers according to server preference`t: " $HALBSSLUseServerPreference                                                   Line 4 "Use ciphers according to server preference`t: " $HALBSSLUseServerPreference
                                        Line 4 "Certificates`t`t`t`t`t: " $HALBSSLCertificates                                                   Line 4 "Certificates`t`t`t`t`t: " $HALBSSLCertificates
                                }                                           }
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $rowdata = @()                                           $rowdata = @()
                                $columnHeaders = @("Port",($Script:htmlsb),$HALBSSLGatewayPort,$htmlwhite)                                           $columnHeaders = @("Port",($Script:htmlsb),$HALBSSLGatewayPort,$htmlwhite)
                                $rowdata += @(,("Mode",($Script:htmlsb),$HALBSSLMode,$htmlwhite))                                           $rowdata += @(,("Mode",($Script:htmlsb),$HALBSSLMode,$htmlwhite))
                                If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")                                           If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")
                                {                                           {
                                        $rowdata += @(,( "Security",($Script:htmlsb), "",$htmlwhite))                                                   $rowdata += @(,( "Security",($Script:htmlsb), "",$htmlwhite))
                                        $rowdata += @(,( "     Accepted SSL Versions",($Script:htmlsb), $HALBSSLAcceptedSSLVersions,$htmlwhite))                                                   $rowdata += @(,( "     Accepted SSL Versions",($Script:htmlsb), $HALBSSLAcceptedSSLVersions,$htmlwhite))
                                        $rowdata += @(,( "     Cipher Strength",($Script:htmlsb), $HALBSSLCipherStrength,$htmlwhite))                                                   $rowdata += @(,( "     Cipher Strength",($Script:htmlsb), $HALBSSLCipherStrength,$htmlwhite))
                                        $rowdata += @(,( "     Cipher",($Script:htmlsb), $HALBSSLCipher,$htmlwhite))                                                   $rowdata += @(,( "     Cipher",($Script:htmlsb), $HALBSSLCipher,$htmlwhite))
                                        $rowdata += @(,( "     Use ciphers according to server preference",($Script:htmlsb), $HALBSSLUseServerPreference,$htmlwhite))                                                   $rowdata += @(,( "     Use ciphers according to server preference",($Script:htmlsb), $HALBSSLUseServerPreference,$htmlwhite))
                                        $rowdata += @(,( "     Certificates",($Script:htmlsb), $HALBSSLCertificates,$htmlwhite))                                                   $rowdata += @(,( "     Certificates",($Script:htmlsb), $HALBSSLCertificates,$htmlwhite))
                                }                                           }
 
                                $msg = "" <>                                         $msg = ""
                                $columnWidths = @("200","400")                                           $columnWidths = @("200","400")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                        }                                   }
 
                        #second, process the gateways <>                                 #second, process the gateways
                        #do output headers                                   #do output headers
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                [System.Collections.Hashtable[]] $GatewaysWordTable = @();                                           [System.Collections.Hashtable[]] $GatewaysWordTable = @();
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 3 "Gateways                                                 Status                                  "                                           Line 3 "Gateways                                                 Status                                  "
                                Line 3 "================================================================================================="                                           Line 3 "================================================================================================="
                                #       abcdefghijklmno.abcdefghijklmno.local (999.999.999.999)SS1234567890123456789012345678901234567890                                           #       abcdefghijklmno.abcdefghijklmno.local (999.999.999.999)SS1234567890123456789012345678901234567890
                                #       1234567890123456789012345678901234567890123456789012345                                           #       1234567890123456789012345678901234567890123456789012345
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $rowdata = @()                                           $rowdata = @()
                        }                                   }
                                                          
                        #process the gateways data                                   #process the gateways data
                        ForEach($GatewayItem in $HALBSSLGateways)                                   ForEach($GWItem in $HALBSSLGateways)
                        {                                   {
                                $ip = $GatewayItem.Keys                                           $ip = $GWItem.Keys
                                $Results = [System.Net.Dns]::gethostentry($ip)                                           $Results = [System.Net.Dns]::gethostentry($ip)
                                $hostname = $Results.HostName                                           $hostname = $Results.HostName
                                $TempGW = Get-RASGatewayStatus -Server $hostname -EA 0 4> $Null                                           $TempGW = Get-RASGWStatus -Server $hostname -EA 0 4> $Null
                                $HALBGWStatus = GetRASStatus $TempGW.AgentState                                           $HALBGWStatus = GetRASStatus $TempGW.AgentState
                                                                          
                                If($MSWord -or $PDF)                                           If($MSWord -or $PDF)
                                {                                           {
                                        $GatewaysWordTableRowHash = @{                                                   $GatewaysWordTableRowHash = @{
                                                Gateway       = "$hostname ($ip)";                                                           Gateway       = "$hostname ($ip)";
                                                GatewayStatus = $HALBGWStatus;                                                           GatewayStatus = $HALBGWStatus;
                                        }                                                   }
                                        $GatewaysWordTable += $GatewaysWordTableRowHash                                                   $GatewaysWordTable += $GatewaysWordTableRowHash
                                }                                           }
                                If($Text)                                           If($Text)
                                {                                           {
                                        Line 3 ( "{0,-55}  {1,-40}" -f "$hostname ($ip)", $HALBGWStatus)                                                   Line 3 ( "{0,-55}  {1,-40}" -f "$hostname ($ip)", $HALBGWStatus)
                                }                                           }
                                If($HTML)                                           If($HTML)
                                {                                           {
                                        $rowdata += @(,(                                                   $rowdata += @(,(
                                        "$hostname ($ip)",$htmlwhite,                                                   "$hostname ($ip)",$htmlwhite,
                                        $HALBGWStatus,$htmlwhite))                                                   $HALBGWStatus,$htmlwhite))
                                }                                           }
                        }                                   }
                                                          
                        #output the Word/PDF and HTML tables                                   #output the Word/PDF and HTML tables
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                If($GatewaysWordTable.Count -gt 0)                                           If($GatewaysWordTable.Count -gt 0)
                                {                                           {
                                        $Table = AddWordTable -Hashtable $GatewaysWordTable `                                                   $Table = AddWordTable -Hashtable $GatewaysWordTable `
                                        -Columns  Gateway,GatewayStatus `                                                   -Columns  Gateway,GatewayStatus `
                                        -Headers  "Gateways","Status"`                                                   -Headers  "Gateways","Status"`
                                        -Format $wdTableGrid `                                                   -Format $wdTableGrid `
                                        -AutoFit $wdAutoFitFixed;                                                   -AutoFit $wdAutoFitFixed;
 
                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15; <>                                                 SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                        $Table.Columns.Item(1).Width = 200; <>                                                 $Table.Columns.Item(1).Width = 200;
                                        $Table.Columns.Item(2).Width = 250;                                                   $Table.Columns.Item(2).Width = 250;
 
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                        FindWordDocumentEnd <>                                                 FindWordDocumentEnd
                                        $Table = $Null                                                   $Table = $Null
                                        WriteWordLine 0 0 ""                                                   WriteWordLine 0 0 ""
                                }                                           }
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $columnHeaders = @(                                           $columnHeaders = @(
                                "Gateways",($Script:htmlsb),                                           "Gateways",($Script:htmlsb),
                                "Status",($Script:htmlsb))                                           "Status",($Script:htmlsb))
 
                                $msg = "" <>                                         $msg = ""
                                $columnWidths = @("200","400")                                           $columnWidths = @("200","400")
                                FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "600"                                           FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "600"
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                        }                                   }
    <#
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                WriteWordLine 4 0 "Device Manager"                                           WriteWordLine 4 0 "Device Manager"
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 2 "Device Manager"                                           Line 2 "Device Manager"
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                #Nothing                                           #Nothing
                        }                                   }
                                                          
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                $ScriptInformation.Add(@{Data = "Port"; Value = "20009"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Port"; Value = ""; }) > $Null
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 3 "Port: 20009"                                           Line 3 "Port: "
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $rowdata = @()                                           $rowdata = @()
                                $columnHeaders = @("Port",($Script:htmlsb),"20009",$htmlwhite)                                           $columnHeaders = @("Port",($Script:htmlsb),"",$htmlwhite)
                                $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
 
                                $msg = "Device Manager" <>                                         $msg = "Device Manager"
                                $columnWidths = @("200","400")                                           $columnWidths = @("200","400")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                        }                                   }
    #>
 
                        Write-Verbose "$(Get-Date -Format G): `tOutput Devices" <>  
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                WriteWordLine 4 0 "Devices"                                           WriteWordLine 4 0 "Devices"
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 2 "Devices"                                           Line 2 "Devices"
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                #Nothing                                           #Nothing
                        }                                   }
                                                          
                        $HALBDevices = Get-RASHALBDevice -HALBName $HALB.Name -EA 0 4> $Null                                   $HALBDevices = Get-RASHALBDevice -HALBName $HALB.Name -EA 0 4> $Null
                                                          
                        If((!$?) -or ($? -and $Null -eq $HALBDevices))                                   If((!$?) -or ($? -and $Null -eq $HALBDevices))
                        {                                   {
                                Write-Host "                                           Write-Host "
                                No HALB Devices retrieved for HALB $($HALB.Name).`                                           No HALB Devices retrieved for HALB $($HALB.Name).`
                                " -ForegroundColor White                                           " -ForegroundColor White
                                If($MSWord -or $PDF)                                           If($MSWord -or $PDF)
                                {                                           {
                                        WriteWordLine 0 0 "No HALB Devices retrieved for HALB $($HALB.Name)"                                                   WriteWordLine 0 0 "No HALB Devices retrieved for HALB $($HALB.Name)"
                                }                                           }
                                If($Text)                                           If($Text)
                                {                                           {
                                        Line 0 "No HALB Devices retrieved for HALB $($HALB.Name)"                                                   Line 0 "No HALB Devices retrieved for HALB $($HALB.Name)"
                                }                                           }
                                If($HTML)                                           If($HTML)
                                {                                           {
                                        WriteHTMLLine 0 0 "No HALB Devices retrieved for HALB $($HALB.Name)"                                                   WriteHTMLLine 0 0 "No HALB Devices retrieved for HALB $($HALB.Name)"
                                }                                           }
                        }                                   }
                        Else                                   Else
                        {                                   {
                                If($MSWord -or $PDF)                                           If($MSWord -or $PDF)
                                {                                           {
                                        [System.Collections.Hashtable[]] $HALBDevicesWordTable = @();                                                   [System.Collections.Hashtable[]] $HALBDevicesWordTable = @();
                                }                                           }
                                If($Text)                                           If($Text)
                                {                                           {
                                        Line 3 "Devices          ID"                                                   Line 3 "Devices          ID"
                                        Line 3 "==================="                                                   Line 3 "==================="
                                        #       999.999.999.999SS12                                                   #       999.999.999.999SS12
                                }                                           }
                                If($HTML)                                           If($HTML)
                                {                                           {
                                        $rowdata = @()                                                   $rowdata = @()
                                }                                           }
                                                                          
                                #process the gateways data                                           #process the gateways data
                                ForEach($HALBDevice in $HALBDevices)                                           ForEach($HALBDevice in $HALBDevices)
                                {                                           {
                                        $ip = $HALBDevice.DeviceIP                                                   $ip = $HALBDevice.DeviceIP
                                        $ID = $HALBDevice.DeviceId                                                   $ID = $HALBDevice.DeviceId
                                                                                          
                                        If($MSWord -or $PDF)                                                   If($MSWord -or $PDF)
                                        {                                                   {
                                                $HALBDevicesWordTableRowHash = @{                                                           $HALBDevicesWordTableRowHash = @{
                                                        DeviceIP = $ip;                                                                   DeviceIP = $ip;
                                                        DeviceID = $ID;                                                                   DeviceID = $ID;
                                                }                                                           }
                                                $HALBDevicesWordTable += $HALBDevicesWordTableRowHash                                                           $HALBDevicesWordTable += $HALBDevicesWordTableRowHash
                                        }                                                   }
                                        If($Text)                                                   If($Text)
                                        {                                                   {
                                                Line 3 ( "{0,-15}  {1,-2}" -f $ip, $ID)                                                           Line 3 ( "{0,-15}  {1,-2}" -f $ip, $ID)
                                        }                                                   }
                                        If($HTML)                                                   If($HTML)
                                        {                                                   {
                                                $rowdata += @(,(                                                           $rowdata += @(,(
                                                $ip,$htmlwhite,                                                           $ip,$htmlwhite,
                                                $ID,$htmlwhite))                                                           $ID,$htmlwhite))
                                        }                                                   }
                                }                                           }
                                                                          
                                #output the Word/PDF and HTML tables                                           #output the Word/PDF and HTML tables
                                If($MSWord -or $PDF)                                           If($MSWord -or $PDF)
                                {                                           {
                                        If($HALBDevicesWordTable.Count -gt 0)                                                   If($HALBDevicesWordTable.Count -gt 0)
                                        {                                                   {
                                                $Table = AddWordTable -Hashtable $HALBDevicesWordTable `                                                           $Table = AddWordTable -Hashtable $HALBDevicesWordTable `
                                                -Columns  DeviceIP,DeviceID `                                                           -Columns  DeviceIP,DeviceID `
                                                -Headers  "Devices","ID" `                                                           -Headers  "Devices","ID" `
                                                -Format $wdTableGrid `                                                           -Format $wdTableGrid `
                                                -AutoFit $wdAutoFitFixed;                                                           -AutoFit $wdAutoFitFixed;
 
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15; <>                                                         SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                                $Table.Columns.Item(1).Width = 100; <>                                                         $Table.Columns.Item(1).Width = 100;
                                                $Table.Columns.Item(2).Width = 50;                                                           $Table.Columns.Item(2).Width = 50;
 
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                                FindWordDocumentEnd <>                                                         FindWordDocumentEnd
                                                $Table = $Null                                                           $Table = $Null
                                                WriteWordLine 0 0 ""                                                           WriteWordLine 0 0 ""
                                        }                                                   }
                                }                                           }
                                If($Text)                                           If($Text)
                                {                                           {
                                        Line 0 ""                                                   Line 0 ""
                                }                                           }
                                If($HTML)                                           If($HTML)
                                {                                           {
                                        $columnHeaders = @(                                                   $columnHeaders = @(
                                        "Devices",($Script:htmlsb),                                                   "Devices",($Script:htmlsb),
                                        "ID",($Script:htmlsb))                                                   "ID",($Script:htmlsb))
 
                                        $msg = "" <>                                                 $msg = ""
                                        $columnWidths = @("100","50")                                                   $columnWidths = @("100","50")
                                        FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "150"                                                   FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "150"
                                        WriteHTMLLine 0 0 ""                                                   WriteHTMLLine 0 0 ""
                                }                                           }
                        }                                   }
 
                        If($MSWord -or $PDF) <>                                 If($MSWord -or $PDF)
                        {                                   {
                                WriteWordLine 4 0 "Advanced"                                           WriteWordLine 4 0 "Advanced"
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 2 "Advanced"                                           Line 2 "Advanced"
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                #Nothing                                           #Nothing
                        }                                   }
                                                          
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                $ScriptInformation.Add(@{Data = "Enable RDP UPD tunneling"; Value = $HALB.EnableUDPTunneling.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Enable RDP UPD tunneling"; Value = $HALB.EnableUDPTunneling.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Maximum TCP connections"; Value = $HALB.MaxTCPConnections.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Maximum TCP connections"; Value = $HALB.MaxTCPConnections.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Client inactivity timeout (s)"; Value = $HALB.ClientIdleTimeout.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Client inactivity timeout (s)"; Value = $HALB.ClientIdleTimeout.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Gateway connection timeout (s)"; Value = $HALB.GatewayConnectionTimeout.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Gateway connection timeout (s)"; Value = $HALB.GWConnectionTimeout.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Client connection queue timeout (s)"; Value = $HALB.ClientQueueTimeout.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Client connection queue timeout (s)"; Value = $HALB.ClientQueueTimeout.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Gateway inactivity timeout (s)"; Value = $HALB.GatewayIdleTimeout.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Gateway inactivity timeout (s)"; Value = $HALB.GatewayIdleTimeout.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Amount of TCP connections per second"; Value = $HALB.SessionsRate.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Amount of TCP connections per second"; Value = $HALB.SessionsRate.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Gateways health check intervals (s)"; Value = $HALB.GatewayHealthCheckInterval.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Gateways health check intervals (s)"; Value = $HALB.GWHealthCheckInterval.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "VRRP virtual router ID"; Value = $HALB.VirtualRouterID.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "VRRP virtual router ID"; Value = $HALB.VirtualRouterID.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "VRRP authentication password"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "VRRP authentication password"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "VRRP broadcast interval (m)"; Value = $HALB.VrrpBroadcastInterval.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "VRRP broadcast interval (m)"; Value = $HALB.VrrpBroadcastInterval.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "VRRP health check script interval (s)"; Value = $HALB.VrrpHealthCheckInterval.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "VRRP health check script interval (s)"; Value = $HALB.VrrpHealthCheckInterval.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "VRRP health check script timeout"; Value = $HALB.VrrpHealthCheckTimeout.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "VRRP health check script timeout"; Value = $HALB.VrrpHealthCheckTimeout.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "VRRP advertisement interval (s)"; Value = $HALB.VrrpAdvertInterval.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "VRRP advertisement interval (s)"; Value = $HALB.VrrpAdvertInterval.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable OS updates"; Value = $HALB.OSUpdate.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Enable OS updates"; Value = $HALB.OSUpdate.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Keep existing load balancing settings"; Value = $HALB.KeepLBProxyConfig.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Keep existing load balancing settings"; Value = $HALB.KeepLBProxyConfig.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Keep existing VRRP/keepalived settings"; Value = $HALB.KeepVRRPConfig.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Keep existing VRRP/keepalive settings"; Value = $HALB.KeepVRRPConfig.ToString(); }) > $Null
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 3 "Enable RDP UPD tunneling`t`t: " $HALB.EnableUDPTunneling.ToString()                                           Line 3 "Enable RDP UPD tunneling`t`t: " $HALB.EnableUDPTunneling.ToString()
                                Line 3 "Maximum TCP connections`t`t`t: " $HALB.MaxTCPConnections.ToString()                                           Line 3 "Maximum TCP connections`t`t`t: " $HALB.MaxTCPConnections.ToString()
                                Line 3 "Client inactivity timeout (s)`t`t: " $HALB.ClientIdleTimeout.ToString()                                           Line 3 "Client inactivity timeout (s)`t`t: " $HALB.ClientIdleTimeout.ToString()
                                Line 3 "Gateway connection timeout (s)`t`t: " $HALB.GatewayConnectionTimeout.ToString()                                           Line 3 "Gateway connection timeout (s)`t`t: " $HALB.GWConnectionTimeout.ToString()
                                Line 3 "Client connection queue timeout (s)`t: " $HALB.ClientQueueTimeout.ToString()                                           Line 3 "Client connection queue timeout (s)`t: " $HALB.ClientQueueTimeout.ToString()
                                Line 3 "Gateway inactivity timeout (s)`t`t: " $HALB.GatewayIdleTimeout.ToString()                                           Line 3 "Gateway inactivity timeout (s)`t`t: " $HALB.GatewayIdleTimeout.ToString()
                                Line 3 "Amount of TCP connections per second`t: " $HALB.SessionsRate.ToString()                                           Line 3 "Amount of TCP connections per second`t: " $HALB.SessionsRate.ToString()
                                Line 3 "Gateways health check intervals (s)`t: " $HALB.GatewayHealthCheckInterval.ToString()                                           Line 3 "Gateways health check intervals (s)`t: " $HALB.GWHealthCheckInterval.ToString()
                                Line 3 "VRRP virtual router ID`t`t`t: " $HALB.VirtualRouterID.ToString()                                           Line 3 "VRRP virtual router ID`t`t`t: " $HALB.VirtualRouterID.ToString()
                                Line 3 "VRRP authentication password`t`t: "                                            Line 3 "VRRP authentication password`t`t: " 
                                Line 3 "VRRP broadcast interval (m)`t`t: " $HALB.VrrpBroadcastInterval.ToString()                                           Line 3 "VRRP broadcast interval (m)`t`t: " $HALB.VrrpBroadcastInterval.ToString()
                                Line 3 "VRRP health check script interval (s)`t: " $HALB.VrrpHealthCheckInterval.ToString()                                           Line 3 "VRRP health check script interval (s)`t: " $HALB.VrrpHealthCheckInterval.ToString()
                                Line 3 "VRRP health check script timeout`t: " $HALB.VrrpHealthCheckTimeout.ToString()                                           Line 3 "VRRP health check script timeout`t: " $HALB.VrrpHealthCheckTimeout.ToString()
                                Line 3 "VRRP advertisement interval (s)`t`t: " $HALB.VrrpAdvertInterval.ToString()                                           Line 3 "VRRP advertisement interval (s)`t`t: " $HALB.VrrpAdvertInterval.ToString()
                                Line 3 "Enable OS updates`t`t`t: " $HALB.OSUpdate.ToString()                                           Line 3 "Enable OS updates`t`t`t: " $HALB.OSUpdate.ToString()
                                Line 3 "Keep existing load balancing settings`t: " $HALB.KeepLBProxyConfig.ToString()                                           Line 3 "Keep existing load balancing settings`t: " $HALB.KeepLBProxyConfig.ToString()
                                Line 3 "Keep existing VRRP/keepalived settings`t: " $HALB.KeepVRRPConfig.ToString()                                           Line 3 "Keep existing VRRP/keepalive settings`t: " $HALB.KeepVRRPConfig.ToString()
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $rowdata = @()                                           $rowdata = @()
                                $columnHeaders = @("Enable RDP UPD tunneling",($Script:htmlsb),$HALB.EnableUDPTunneling.ToString(),$htmlwhite)                                           $columnHeaders = @("Enable RDP UPD tunneling",($Script:htmlsb),$HALB.EnableUDPTunneling.ToString(),$htmlwhite)
                                $rowdata += @(,("Maximum TCP connections",($Script:htmlsb),$HALB.MaxTCPConnections.ToString(),$htmlwhite))                                           $rowdata += @(,("Maximum TCP connections",($Script:htmlsb),$HALB.MaxTCPConnections.ToString(),$htmlwhite))
                                $rowdata += @(,("Client inactivity timeout (s)",($Script:htmlsb),$HALB.ClientIdleTimeout.ToString(),$htmlwhite))                                           $rowdata += @(,("Client inactivity timeout (s)",($Script:htmlsb),$HALB.ClientIdleTimeout.ToString(),$htmlwhite))
                                $rowdata += @(,("Gateway connection timeout (s)",($Script:htmlsb),$HALB.GatewayConnectionTimeout.ToString(),$htmlwhite))                                           $rowdata += @(,("Gateway connection timeout (s)",($Script:htmlsb),$HALB.GWConnectionTimeout.ToString(),$htmlwhite))
                                $rowdata += @(,("Client connection queue timeout (s)",($Script:htmlsb),$HALB.ClientQueueTimeout.ToString(),$htmlwhite))                                           $rowdata += @(,("Client connection queue timeout (s)",($Script:htmlsb),$HALB.ClientQueueTimeout.ToString(),$htmlwhite))
                                $rowdata += @(,("Gateway inactivity timeout (s)",($Script:htmlsb),$HALB.GatewayIdleTimeout.ToString(),$htmlwhite))                                           $rowdata += @(,("Gateway inactivity timeout (s)",($Script:htmlsb),$HALB.GatewayIdleTimeout.ToString(),$htmlwhite))
                                $rowdata += @(,("Amount of TCP connections per second",($Script:htmlsb),$HALB.SessionsRate.ToString(),$htmlwhite))                                           $rowdata += @(,("Amount of TCP connections per second",($Script:htmlsb),$HALB.SessionsRate.ToString(),$htmlwhite))
                                $rowdata += @(,("Gateways health check intervals (s)",($Script:htmlsb),$HALB.GatewayHealthCheckInterval.ToString(),$htmlwhite))                                           $rowdata += @(,("Gateways health check intervals (s)",($Script:htmlsb),$HALB.GWHealthCheckInterval.ToString(),$htmlwhite))
                                $rowdata += @(,("VRRP virtual router ID",($Script:htmlsb),$HALB.VirtualRouterID.ToString(),$htmlwhite))                                           $rowdata += @(,("VRRP virtual router ID",($Script:htmlsb),$HALB.VirtualRouterID.ToString(),$htmlwhite))
                                $rowdata += @(,("VRRP authentication password",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("VRRP authentication password",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("VRRP broadcast interval (m)",($Script:htmlsb),$HALB.VrrpBroadcastInterval.ToString(),$htmlwhite))                                           $rowdata += @(,("VRRP broadcast interval (m)",($Script:htmlsb),$HALB.VrrpBroadcastInterval.ToString(),$htmlwhite))
                                $rowdata += @(,("VRRP health check script interval (s)",($Script:htmlsb),$HALB.VrrpHealthCheckInterval.ToString(),$htmlwhite))                                           $rowdata += @(,("VRRP health check script interval (s)",($Script:htmlsb),$HALB.VrrpHealthCheckInterval.ToString(),$htmlwhite))
                                $rowdata += @(,("VRRP health check script timeout",($Script:htmlsb),$HALB.VrrpHealthCheckTimeout.ToString(),$htmlwhite))                                           $rowdata += @(,("VRRP health check script timeout",($Script:htmlsb),$HALB.VrrpHealthCheckTimeout.ToString(),$htmlwhite))
                                $rowdata += @(,("VRRP advertisement interval (s)",($Script:htmlsb),$HALB.VrrpAdvertInterval.ToString(),$htmlwhite))                                           $rowdata += @(,("VRRP advertisement interval (s)",($Script:htmlsb),$HALB.VrrpAdvertInterval.ToString(),$htmlwhite))
                                $rowdata += @(,("Enable OS updates",($Script:htmlsb),$HALB.OSUpdate.ToString(),$htmlwhite))                                           $rowdata += @(,("Enable OS updates",($Script:htmlsb),$HALB.OSUpdate.ToString(),$htmlwhite))
                                $rowdata += @(,("Keep existing load balancing settings",($Script:htmlsb),$HALB.KeepLBProxyConfig.ToString(),$htmlwhite))                                           $rowdata += @(,("Keep existing load balancing settings",($Script:htmlsb),$HALB.KeepLBProxyConfig.ToString(),$htmlwhite))
                                $rowdata += @(,("Keep existing VRRP/keepalived settings",($Script:htmlsb),$HALB.KeepVRRPConfig.ToString(),$htmlwhite))                                           $rowdata += @(,("Keep existing VRRP/keepalive settings",($Script:htmlsb),$HALB.KeepVRRPConfig.ToString(),$htmlwhite))
 
                                $msg = "Advanced" <>                                         $msg = "Advanced"
                                $columnWidths = @("200","400")                                           $columnWidths = @("200","400")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                                    }
 
        If($MSWord -or $PDF) +-  
        {    
                WriteWordLine 2 0 "Themes"    
        }    
        If($Text)    
        {    
                Line 1 "Themes"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Themes"    
        }    
     
        Write-Verbose "$(Get-Date -Format G): Output Themes"    
 
        No Themes retrieved for Site $($Site.Name).` <>                 No Themes retrieved for Site $($Site.Name).`
 
  -+                 If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 "Themes"
                    }
                    If($Text)
                    {
                            Line 1 "Themes"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "Themes"
                    }
     
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Themes"
 
                        $ThemeUserPortalPrelogonMessage    = $Theme.UserPortal.Message.PreLogonMessage.Split("`n") <>                         $ThemeHTML5PrelogonMessage    = $Theme.HTML5Client.Message.PreLogonMessage.Split("`n")
                        $ThemeUserPortalPostlogonMessage   = $Theme.UserPortal.Message.UserPortalPostLogonMessage.Split("`n")                           $ThemeHTML5PostlogonMessage   = $Theme.HTML5Client.Message.HTML5PostLogonMessage.Split("`n")
 
                        $ThemeUserPortalURL                = "https://FQDN/$($Theme.UserPortal.Url.LoginPageURLPath)" <>                         $ThemeHTML5URL                = "https://FQDN/$($Theme.HTML5Client.Url.LoginPageURLPath)"
                        $ThemeShowDownloadURL         = $Theme.UserPortal.Url.ShowDownloadURL.ToString()                           $ThemeShowDownloadURL         = $Theme.HTML5Client.Url.ShowDownloadURL.ToString()
                        $ThemeOverrideDownloadURL     = $Theme.UserPortal.Url.OverrideWindowsClientDownloadURL                           $ThemeOverrideDownloadURL     = $Theme.HTML5Client.Url.OverrideWindowsClientDownloadURL
 
                        $ThemeUserPortalLaunchSessionsUsing = "" <>                         $ThemeHTML5LaunchSessionsUsing = ""
                        Switch($Theme.UserPortal.Gateway.LaunchMethod)                           Switch($Theme.HTML5Client.Gateway.LaunchMethod)
 
                                        $ThemeUserPortalLaunchSessionsUsing = "Launch apps with Parallels Client & Fallback to HTML5"; Break <>                                         $ThemeHTML5LaunchSessionsUsing = "Launch apps with Parallels Client & Fallback to HTML5"; Break
 
                                        $ThemeUserPortalLaunchSessionsUsing = "Launch apps with Parallels Client"; Break <>                                         $ThemeHTML5LaunchSessionsUsing = "Launch apps with Parallels Client"; Break
 
                                        $ThemeUserPortalLaunchSessionsUsing = "Launch apps in Browser only (HTML5 Only)"; Break <>                                         $ThemeHTML5LaunchSessionsUsing = "Launch apps in Browser only (HTML5 Only)"; Break
 
                                        $ThemeUserPortalLaunchSessionsUsing = "Unable to determine Launch sessions using: $($Theme.UserPortal.Gateway.LaunchMethod)"; Break <>                                         $ThemeHTML5LaunchSessionsUsing = "Unable to determine Launch sessions using: $($Theme.HTML5Client.Gateway.LaunchMethod)"; Break
 
                        Switch($Theme.UserPortal.Gateway.FileTransferMode) <>                         Switch($Theme.HTML5Client.Gateway.FileTransferMode)
 
                                Default                         {$ThemeHTMLFileTransfer = "Unable to determine File transfer mode: $($Theme.UserPortal.Gateway.FileTransferMode)"; Break} <>                                 Default                         {$ThemeHTMLFileTransfer = "Unable to determine File transfer mode: $($Theme.HTML5Client.Gateway.FileTransferMode)"; Break}
 
                        Switch($Theme.UserPortal.Gateway.ClipboardDirection) <>                         Switch($Theme.HTML5Client.Gateway.ClipboardDirection)
 
                                Default                         {$ThemeHTMLClipboardDirection = "Unable to determine Clipboard direction: $($Theme.UserPortal.Gateway.ClipboardDirection)"; Break} <>                                 Default                         {$ThemeHTMLClipboardDirection = "Unable to determine Clipboard direction: $($Theme.HTML5Client.Gateway.ClipboardDirection)"; Break}
 
                                $ScriptInformation.Add(@{Data = "HTML5 URL"; Value = $ThemeUserPortalURL; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "HTML5 URL"; Value = $ThemeHTML5URL; }) > $Null
 
                                Line 3 "HTML5 URL`t`t: " $ThemeUserPortalURL <>                                 Line 3 "HTML5 URL`t`t: " $ThemeHTML5URL
 
                                $rowdata += @(,("HTML5 URL",($Script:htmlsb),$ThemeUserPortalURL,$htmlwhite)) <>                                 $rowdata += @(,("HTML5 URL",($Script:htmlsb),$ThemeHTML5URL,$htmlwhite))
 
                                Line 0 "" +-  
                        }    
                        If($HTML)    
                        {    
                                $ThemeName = $Theme.Name.Replace("<","").Replace(">","")    
                                $rowdata = @()    
                                $columnHeaders = @("Enable Theme",($Script:htmlsb),$Theme.Enabled.ToString(),$htmlwhite)    
                                $rowdata += @(,("Name",($Script:htmlsb),$ThemeName,$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$Theme.Description,$htmlwhite))    
     
                                $msg = "General"    
                                $columnWidths = @("200","400")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Access"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Access"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        $Results = Get-RASMFA -Id $Theme.MFAId -EA 0 4>$Null    
                            
                        If($? -and $Null -ne $Results)    
                        {    
                                $MFAProvider = $Results.Name    
                        }    
                        Else    
                        {    
                                $MFAProvider = "Unable to determine MFA provider"    
                        }    
                            
                        $Results = Get-RASSAMLIDP -SiteId $Site.Id -EA 0 4>$Null | Where-Object {$_.ThemeId -eq $Theme.Id}    
                            
                        If($? -and $Null -ne $Results)    
                        {    
                                $SAMLProvider = $Results.Name    
                        }    
                        Else    
                        {    
                                $SAMLProvider = ""    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Override authentication domain"; Value = $Theme.OverrideAuthenticationDomain.ToString(); }) > $Null    
                                If($Theme.OverrideAuthenticationDomain)    
                                {    
                                        $ScriptInformation.Add(@{Data = "     Domain"; Value = $Theme.Domain; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "Limit access to this theme to members of these AD groups"; Value = $Theme.GroupEnabled.ToString(); }) > $Null    
                                If($Theme.GroupEnabled)    
                                {    
                                        ForEach($Group in $Theme.GroupFilters)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Group: $($Group.name) SID: $($Group.sid)"; }) > $Null    
                                        }    
                                }    
                                $ScriptInformation.Add(@{Data = "MFA provider"; Value = $MFAProvider; }) > $Null    
                                $ScriptInformation.Add(@{Data = "SAML Single Sign-in IdP"; Value = $SAMLProvider; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
 
                                Line 3 "MFA provider`t`t`t: " $MFAProvider +-  
                                Line 3 "SAML Single Sign-in IdP`t`t: " $SAMLProvider    
 
  <>                                 $columnHeaders = @("Enable Theme",($Script:htmlsb),$Theme.Enabled.ToString(),$htmlwhite)
                                    $rowdata += @(,("Name",($Script:htmlsb),$ThemeName,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$Theme.Description,$htmlwhite))
                                $columnHeaders = @("Override authentication domain",($Script:htmlsb),$Theme.OverrideAuthenticationDomain.ToString(),$htmlwhite)                                   $rowdata += @(,("Override authentication domain",($Script:htmlsb),$Theme.OverrideAuthenticationDomain.ToString(),$htmlwhite))
 
                                $rowdata += @(,("MFA provider",($Script:htmlsb),$MFAProvider,$htmlwhite)) <>  
                                $rowdata += @(,("SAML Single Sign-in IdP",($Script:htmlsb),$SAMLProvider,$htmlwhite))    
                                    
                                $msg = "Access"                                   $msg = "General"
 
                                WriteWordLine 4 0 "User Portal (Web client)/URLs" <>                                 WriteWordLine 4 0 "HTML5 client/URLs"
 
                                Line 2 "User Portal (Web client)/URLs" <>                                 Line 2 "HTML5 client/URLs"
 
                                $ScriptInformation.Add(@{Data = "Theme login page:"; Value = $ThemeUserPortalURL; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Theme login page:"; Value = $ThemeHTML5URL; }) > $Null
 
                                        WriteWordLine 4 0 "Footer URLs:" <>  
                                        WriteWordLine 0 0 "There are no Footer URLs"                                           WriteWordLine 0 1 "There are no Footer URLs"
                                        WriteWordLine 0 0 ""    
 
                                Line 3 "Theme login page`t`t  : " $ThemeUserPortalURL <>                                 Line 3 "Theme login page`t`t  : " $ThemeHTML5URL
 
                                        Line 3 "Footer URLs:" +-  
 
                                        Line 0 "" +-  
 
                                $columnHeaders = @("Theme login page:",($Script:htmlsb),$ThemeUserPortalURL,$htmlwhite) <>                                 $columnHeaders = @("Theme login page:",($Script:htmlsb),$ThemeHTML5URL,$htmlwhite)
 
                                $msg = "User Portal (Web client)/URLs" <>                                 $msg = "HTML5 client/URLs"
 
                                        WriteHTMLLine 4 0 "Footer URLs:" <>  
                                        WriteHTMLLine 0 0 "There are no Footer URLs"                                           WriteHTMLLine 0 1 "There are no Footer URLs"
                                        WriteHTMLLine 0 0 ""    
 
                                WriteWordLine 4 0 "User Portal (Web client)/Branding" <>                                 WriteWordLine 4 0 "HTML5 client/Branding"
 
                                Line 2 "User Portal (Web client)/Branding" <>                                 Line 2 "HTML5 client/Branding"
 
                                $ScriptInformation.Add(@{Data = "Webpage title"; Value = $Theme.UserPortal.Branding.WebpageTitle; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Webpage title"; Value = $Theme.HTML5Client.Branding.WebpageTitle; }) > $Null
                                $ScriptInformation.Add(@{Data = "Login to"; Value = $Theme.UserPortal.Branding.LoginTo; }) > $Null                                   $ScriptInformation.Add(@{Data = "Login to"; Value = $Theme.HTML5Client.Branding.LoginTo; }) > $Null
 
                                Line 3 "Webpage title`t: " $Theme.UserPortal.Branding.WebpageTitle <>                                 Line 3 "Webpage title`t: " $Theme.HTML5Client.Branding.WebpageTitle
                                Line 3 "Login to`t: " $Theme.UserPortal.Branding.LoginTo                                   Line 3 "Login to`t: " $Theme.HTML5Client.Branding.LoginTo
 
                                $columnHeaders = @("Webpage title",($Script:htmlsb),$Theme.UserPortal.Branding.WebpageTitle,$htmlwhite) <>                                 $columnHeaders = @("Webpage title",($Script:htmlsb),$Theme.HTML5Client.Branding.WebpageTitle,$htmlwhite)
                                $rowdata += @(,("Login to",($Script:htmlsb),$Theme.UserPortal.Branding.LoginTo,$htmlwhite))                                   $rowdata += @(,("Login to",($Script:htmlsb),$Theme.HTML5Client.Branding.LoginTo,$htmlwhite))
 
                                $msg = "User Portal (Web client)/Branding" <>                                 $msg = "HTML5 client/Branding"
 
  +-  
 
                                WriteWordLine 4 0 "User Portal (Web client)/Colors" <>                                 WriteWordLine 4 0 "HTML5 client/Language bar"
 
                                Line 2 "User Portal (Web client)/Colors" <>                                 Line 2 "HTML5 client/Language bar"
 
  <>                         
                        $HeaderBackgroundColor      = '{0:X}' -f $Theme.UserPortal.Color.HeaderBackgroundColor         
                        $SubHeaderBackgroundColor   = '{0:X}' -f $Theme.UserPortal.Color.SubHeaderBackgroundColor      
                        $SubHeaderTextColor         = '{0:X}' -f $Theme.UserPortal.Color.SubHeaderTextColor            
                        $WorkAreaBackgroundColor    = '{0:X}' -f $Theme.UserPortal.Color.WorkAreaBackgroundColor       
                        $WorkAreaTextColor          = '{0:X}' -f $Theme.UserPortal.Color.WorkAreaTextColor             
                        $ButtonsBackgroundColor     = '{0:X}' -f $Theme.UserPortal.Color.ButtonsBackgroundColor        
                        $ButtonsTextColor           = '{0:X}' -f $Theme.UserPortal.Color.ButtonsTextColor              
                        $SelectionHighlightingColor = '{0:X}' -f $Theme.UserPortal.Color.SelectionHighlightingColor    
                        $AlertBackgroundColor       = '{0:X}' -f $Theme.UserPortal.Color.AlertBackgroundColor          
                        $AlertTextColor             = '{0:X}' -f $Theme.UserPortal.Color.AlertTextColor                
     
 
  <>                                 $ScriptInformation.Add(@{Data = "Default language"   ; Value = $Theme.HTML5Client.LanguageBar.Default.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Header background" ; Value = $HeaderBackgroundColor; }) > $Null                                   $ScriptInformation.Add(@{Data = "English           ; Value = $Theme.HTML5Client.LanguageBar.en_US.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Sub-header background" ; Value = $SubHeaderBackgroundColor; }) > $Null                                   $ScriptInformation.Add(@{Data = "German"             ; Value = $Theme.HTML5Client.LanguageBar.de_DE.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Sub-header text" ; Value = $SubHeaderTextColor; }) > $Null                                   $ScriptInformation.Add(@{Data = "Japanese"           ; Value = $Theme.HTML5Client.LanguageBar.ja_JP.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Work area background" ; Value = $WorkAreaBackgroundColor; }) > $Null                                   $ScriptInformation.Add(@{Data = "Russian"            ; Value = $Theme.HTML5Client.LanguageBar.ru_RU.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Work area text" ; Value = $WorkAreaTextColor; }) > $Null                                   $ScriptInformation.Add(@{Data = "French"             ; Value = $Theme.HTML5Client.LanguageBar.fr_FR.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Buttons background and links" ; Value = $ButtonsBackgroundColor; }) > $Null                                   $ScriptInformation.Add(@{Data = "Spanish"            ; Value = $Theme.HTML5Client.LanguageBar.es_ES.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Italian"            ; Value = $Theme.HTML5Client.LanguageBar.it_IT.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Button text" ; Value = $ButtonsTextColor; }) > $Null                                   $ScriptInformation.Add(@{Data = "Portuguese"         ; Value = $Theme.HTML5Client.LanguageBar.pt_BR.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Selection highlighting" ; Value = $SelectionHighlightingColor; }) > $Null                                   $ScriptInformation.Add(@{Data = "Chinese Simplified" ; Value = $Theme.HTML5Client.LanguageBar.zh_CN.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Chinese Traditional"; Value = $Theme.HTML5Client.LanguageBar.zh_TW.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Alert background" ; Value = $AlertBackgroundColor; }) > $Null                                   $ScriptInformation.Add(@{Data = "Korean"             ; Value = $Theme.HTML5Client.LanguageBar.ko_KR.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Alert text" ; Value = $AlertTextColor; }) > $Null                                   $ScriptInformation.Add(@{Data = "Dutch"              ; Value = $Theme.HTML5Client.LanguageBar.nl_NL.ToString(); }) > $Null
 
                                Line 3 "Header background`t`t: " $HeaderBackgroundColor <>  
                                Line 3 "Sub-header background`t`t: " $SubHeaderBackgroundColor    
                                Line 3 "Sub-header text`t`t`t: " $SubHeaderTextColor    
                                Line 3 "Work area background`t`t: " $WorkAreaBackgroundColor    
                                Line 3 "Work area text`t`t`t: " $WorkAreaTextColor    
                                Line 3 "Buttons background and links`t: " $ButtonsBackgroundColor    
                                Line 3 "Button text`t`t`t: " $ButtonsTextColor    
                                Line 3 "Selection highlighting`t`t: " $SelectionHighlightingColor    
                                Line 3 "Alert background`t`t: " $AlertBackgroundColor    
                                Line 3 "Alert text`t`t`t: " $AlertTextColor    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Header background" ,($Script:htmlsb),$HeaderBackgroundColor,$htmlwhite)    
                                $rowdata += @(,("Sub-header background" ,($Script:htmlsb),$SubHeaderBackgroundColor,$htmlwhite))    
                                $rowdata += @(,("Sub-header text" ,($Script:htmlsb),$SubHeaderTextColor,$htmlwhite))    
                                $rowdata += @(,("Work area background" ,($Script:htmlsb),$WorkAreaBackgroundColor,$htmlwhite))    
                                $rowdata += @(,("Work area text" ,($Script:htmlsb),$WorkAreaTextColor,$htmlwhite))    
                                $rowdata += @(,("Buttons background and links",($Script:htmlsb),$ButtonsBackgroundColor,$htmlwhite))    
                                $rowdata += @(,("Button text" ,($Script:htmlsb),$ButtonsTextColor,$htmlwhite))    
                                $rowdata += @(,("Selection highlighting" ,($Script:htmlsb),$SelectionHighlightingColor,$htmlwhite))    
                                $rowdata += @(,("Alert background" ,($Script:htmlsb),$AlertBackgroundColor,$htmlwhite))    
                                $rowdata += @(,("Alert text" ,($Script:htmlsb),$AlertTextColor,$htmlwhite))    
     
                                $msg = "User Portal (Web client)/Colors"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "User Portal (Web client)/Language bar"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "User Portal (Web client)/Language bar"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Default language"   ; Value = $Theme.UserPortal.LanguageBar.Default.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "English"            ; Value = $Theme.UserPortal.LanguageBar.en_US.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "German"             ; Value = $Theme.UserPortal.LanguageBar.de_DE.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Japanese"           ; Value = $Theme.UserPortal.LanguageBar.ja_JP.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Russian"            ; Value = $Theme.UserPortal.LanguageBar.ru_RU.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "French"             ; Value = $Theme.UserPortal.LanguageBar.fr_FR.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Spanish"            ; Value = $Theme.UserPortal.LanguageBar.es_ES.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Italian"            ; Value = $Theme.UserPortal.LanguageBar.it_IT.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Portuguese"         ; Value = $Theme.UserPortal.LanguageBar.pt_BR.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Chinese Simplified" ; Value = $Theme.UserPortal.LanguageBar.zh_CN.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Chinese Traditional"; Value = $Theme.UserPortal.LanguageBar.zh_TW.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Korean"             ; Value = $Theme.UserPortal.LanguageBar.ko_KR.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Dutch"              ; Value = $Theme.UserPortal.LanguageBar.nl_NL.ToString(); }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Default language`t: "    $Theme.UserPortal.LanguageBar.Default.ToString()                                   Line 3 "Default language`t: "    $Theme.HTML5Client.LanguageBar.Default.ToString()
                                Line 3 "English`t`t`t: "         $Theme.UserPortal.LanguageBar.en_US.ToString()                                   Line 3 "English`t`t`t: "         $Theme.HTML5Client.LanguageBar.en_US.ToString()
                                Line 3 "German`t`t`t: "          $Theme.UserPortal.LanguageBar.de_DE.ToString()                                   Line 3 "German`t`t`t: "          $Theme.HTML5Client.LanguageBar.de_DE.ToString()
                                Line 3 "Japanese`t`t: "          $Theme.UserPortal.LanguageBar.ja_JP.ToString()                                   Line 3 "Japanese`t`t: "          $Theme.HTML5Client.LanguageBar.ja_JP.ToString()
                                Line 3 "Russian`t`t`t: "         $Theme.UserPortal.LanguageBar.ru_RU.ToString()                                   Line 3 "Russian`t`t`t: "         $Theme.HTML5Client.LanguageBar.ru_RU.ToString()
                                Line 3 "French`t`t`t: "          $Theme.UserPortal.LanguageBar.fr_FR.ToString()                                   Line 3 "French`t`t`t: "          $Theme.HTML5Client.LanguageBar.fr_FR.ToString()
                                Line 3 "Spanish`t`t`t: "         $Theme.UserPortal.LanguageBar.es_ES.ToString()                                   Line 3 "Spanish`t`t`t: "         $Theme.HTML5Client.LanguageBar.es_ES.ToString()
                                Line 3 "Italian`t`t`t: "         $Theme.UserPortal.LanguageBar.it_IT.ToString()                                   Line 3 "Italian`t`t`t: "         $Theme.HTML5Client.LanguageBar.it_IT.ToString()
                                Line 3 "Portuguese`t`t: "        $Theme.UserPortal.LanguageBar.pt_BR.ToString()                                   Line 3 "Portuguese`t`t: "        $Theme.HTML5Client.LanguageBar.pt_BR.ToString()
                                Line 3 "Chinese Simplified`t: "  $Theme.UserPortal.LanguageBar.zh_CN.ToString()                                   Line 3 "Chinese Simplified`t: "  $Theme.HTML5Client.LanguageBar.zh_CN.ToString()
                                Line 3 "Chinese Traditional`t: " $Theme.UserPortal.LanguageBar.zh_TW.ToString()                                   Line 3 "Chinese Traditional`t: " $Theme.HTML5Client.LanguageBar.zh_TW.ToString()
                                Line 3 "Korean`t`t`t: "          $Theme.UserPortal.LanguageBar.ko_KR.ToString()                                   Line 3 "Korean`t`t`t: "          $Theme.HTML5Client.LanguageBar.ko_KR.ToString()
                                Line 3 "Dutch`t`t`t: "           $Theme.UserPortal.LanguageBar.nl_NL.ToString()                                   Line 3 "Dutch`t`t`t: "           $Theme.HTML5Client.LanguageBar.nl_NL.ToString()
 
                                $columnHeaders = @("Default language",($Script:htmlsb),$Theme.UserPortal.LanguageBar.Default.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Default language",($Script:htmlsb),$Theme.HTML5Client.LanguageBar.Default.ToString(),$htmlwhite)
                                $rowdata += @(,("English"            ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.en_US.ToString(),$htmlwhite))                                   $rowdata += @(,("English"            ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.en_US.ToString(),$htmlwhite))
                                $rowdata += @(,("German"             ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.de_DE.ToString(),$htmlwhite))                                   $rowdata += @(,("German"             ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.de_DE.ToString(),$htmlwhite))
                                $rowdata += @(,("Japanese"           ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.ja_JP.ToString(),$htmlwhite))                                   $rowdata += @(,("Japanese"           ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.ja_JP.ToString(),$htmlwhite))
                                $rowdata += @(,("Russian"            ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.ru_RU.ToString(),$htmlwhite))                                   $rowdata += @(,("Russian"            ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.ru_RU.ToString(),$htmlwhite))
                                $rowdata += @(,("French"             ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.fr_FR.ToString(),$htmlwhite))                                   $rowdata += @(,("French"             ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.fr_FR.ToString(),$htmlwhite))
                                $rowdata += @(,("Spanish"            ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.es_ES.ToString(),$htmlwhite))                                   $rowdata += @(,("Spanish"            ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.es_ES.ToString(),$htmlwhite))
                                $rowdata += @(,("Italian"            ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.it_IT.ToString(),$htmlwhite))                                   $rowdata += @(,("Italian"            ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.it_IT.ToString(),$htmlwhite))
                                $rowdata += @(,("Portuguese"         ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.pt_BR.ToString(),$htmlwhite))                                   $rowdata += @(,("Portuguese"         ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.pt_BR.ToString(),$htmlwhite))
                                $rowdata += @(,("Chinese Simplified" ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.zh_CN.ToString(),$htmlwhite))                                   $rowdata += @(,("Chinese Simplified" ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.zh_CN.ToString(),$htmlwhite))
                                $rowdata += @(,("Chinese Traditional",($Script:htmlsb),$Theme.UserPortal.LanguageBar.zh_TW.ToString(),$htmlwhite))                                   $rowdata += @(,("Chinese Traditional",($Script:htmlsb),$Theme.HTML5Client.LanguageBar.zh_TW.ToString(),$htmlwhite))
                                $rowdata += @(,("Korean"             ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.ko_KR.ToString(),$htmlwhite))                                   $rowdata += @(,("Korean"             ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.ko_KR.ToString(),$htmlwhite))
                                $rowdata += @(,("Dutch"              ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.nl_NL.ToString(),$htmlwhite))                                   $rowdata += @(,("Dutch"              ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.nl_NL.ToString(),$htmlwhite))
 
                                $msg = "User Portal (Web client)/Language bar" <>                                 $msg = "HTML5 client/Language bar"
 
                                WriteWordLine 4 0 "User Portal (Web client)/Messages" <>                                 WriteWordLine 4 0 "HTML5 client/Messages"
 
                                Line 2 "User Portal (Web client)/Messages" <>                                 Line 2 "HTML5 client/Messages"
 
                                ForEach($line in $ThemeUserPortalPrelogonMessage) <>                                 ForEach($line in $ThemeHTML5PrelogonMessage)
 
                                $ScriptInformation.Add(@{Data = "Override post-logon message"; Value = $Theme.UserPortal.Message.OverridePostLogonMessage.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Override post-logon message"; Value = $Theme.HTML5Client.Message.OverridePostLogonMessage.ToString(); }) > $Null
                                If($Theme.UserPortal.Message.OverridePostLogonMessage)                                   If($Theme.HTML5Client.Message.OverridePostLogonMessage)
 
                                        ForEach($line in $ThemeUserPortalPostlogonMessage) <>                                         ForEach($line in $ThemeHTML5PostlogonMessage)
 
                                ForEach($line in $ThemeUserPortalPrelogonMessage) <>                                 ForEach($line in $ThemeHTML5PrelogonMessage)
 
                                Line 3 "Override post-logon message: " $Theme.UserPortal.Message.OverridePostLogonMessage.ToString() <>                                 Line 3 "Override post-logon message: " $Theme.HTML5Client.Message.OverridePostLogonMessage.ToString()
                                If($Theme.UserPortal.Message.OverridePostLogonMessage)                                   If($Theme.HTML5Client.Message.OverridePostLogonMessage)
 
                                        ForEach($line in $ThemeUserPortalPostlogonMessage) <>                                         ForEach($line in $ThemeHTML5PostlogonMessage)
 
                                ForEach($line in $ThemeUserPortalPrelogonMessage) <>                                 ForEach($line in $ThemeHTML5PrelogonMessage)
 
                                $msg = "User Portal (Web client)/Messages" <>                                 $msg = "HTML5 client/Messages"
 
                                $columnHeaders = @("Override post-logon message",($Script:htmlsb),$Theme.UserPortal.Message.OverridePostLogonMessage.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Override post-logon message",($Script:htmlsb),$Theme.HTML5Client.Message.OverridePostLogonMessage.ToString(),$htmlwhite)
                                If($Theme.UserPortal.Message.OverridePostLogonMessage)                                   If($Theme.HTML5Client.Message.OverridePostLogonMessage)
 
                                        ForEach($line in $ThemeUserPortalPostlogonMessage) <>                                         ForEach($line in $ThemeHTML5PostlogonMessage)
 
                                WriteWordLine 4 0 "User Portal (Web client)/Input prompt" <>  
                        }    
                        If($Text)    
                        {    
                                Line 2 "User Portal (Web client)/Input prompt"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        $InputPromptTable = @()    
                            
                        $InputPromptTable += @{    
                                Language = "German"    
                                LoginHint = $Theme.UserPortal.InputPrompt.de_DE.LoginHint    
                                PasswordHint = $Theme.UserPortal.InputPrompt.de_DE.PasswordHint    
                        }    
     
                        $InputPromptTable += @{    
                                Language = "English"    
                                LoginHint = $Theme.UserPortal.InputPrompt.en_US.LoginHint    
                                PasswordHint = $Theme.UserPortal.InputPrompt.en_US.PasswordHint    
                        }    
     
                        $InputPromptTable += @{    
                                Language = "Japanese"    
                                LoginHint = $Theme.UserPortal.InputPrompt.ja_JP.LoginHint    
                                PasswordHint = $Theme.UserPortal.InputPrompt.ja_JP.PasswordHint    
                        }    
     
                        $InputPromptTable += @{    
                                Language = "Russian"    
                                LoginHint = $Theme.UserPortal.InputPrompt.ru_RU.LoginHint    
                                PasswordHint = $Theme.UserPortal.InputPrompt.ru_RU.PasswordHint    
                        }    
     
                        $InputPromptTable += @{    
                                Language = "French"    
                                LoginHint = $Theme.UserPortal.InputPrompt.fr_FR.LoginHint    
                                PasswordHint = $Theme.UserPortal.InputPrompt.fr_FR.PasswordHint    
                        }    
     
                        $InputPromptTable += @{    
                                Language = "Spanish"    
                                LoginHint = $Theme.UserPortal.InputPrompt.es_ES.LoginHint    
                                PasswordHint = $Theme.UserPortal.InputPrompt.es_ES.PasswordHint    
                        }    
     
                        $InputPromptTable += @{    
                                Language = "Italian"    
                                LoginHint = $Theme.UserPortal.InputPrompt.it_IT.LoginHint    
                                PasswordHint = $Theme.UserPortal.InputPrompt.it_IT.PasswordHint    
                        }    
     
                        $InputPromptTable += @{    
                                Language = "Portuguese"    
                                LoginHint = $Theme.UserPortal.InputPrompt.pt_BR.LoginHint    
                                PasswordHint = $Theme.UserPortal.InputPrompt.pt_BR.PasswordHint    
                        }    
     
                        $InputPromptTable += @{    
                                Language = "Chinese Simplified"    
                                LoginHint = $Theme.UserPortal.InputPrompt.zh_CN.LoginHint    
                                PasswordHint = $Theme.UserPortal.InputPrompt.zh_CN.PasswordHint    
                        }    
     
                        $InputPromptTable += @{    
                                Language = "Chinese Traditional"    
                                LoginHint = $Theme.UserPortal.InputPrompt.zh_TW.LoginHint    
                                PasswordHint = $Theme.UserPortal.InputPrompt.zh_TW.PasswordHint    
                        }    
     
                        $InputPromptTable += @{    
                                Language = "Korean"    
                                LoginHint = $Theme.UserPortal.InputPrompt.ko_KR.LoginHint    
                                PasswordHint = $Theme.UserPortal.InputPrompt.ko_KR.PasswordHint    
                        }    
     
                        $InputPromptTable += @{    
                                Language = "Dutch"    
                                LoginHint = $Theme.UserPortal.InputPrompt.nl_NL.LoginHint    
                                PasswordHint = $Theme.UserPortal.InputPrompt.nl_NL.PasswordHint    
                        }    
     
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
     
                                If($InputPromptTable.Count -gt 0)    
                                {    
                                        $Table = AddWordTable -Hashtable $InputPromptTable `    
                                        -Columns Language, LoginHint, PasswordHint `    
                                        -Headers "Language", "Login hint", "Password hint" `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 100;    
                                        $Table.Columns.Item(2).Width = 100;    
                                        $Table.Columns.Item(3).Width = 100;    
                                            
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Language             Login hint           Password hint"    
                                Line 3 "======================================================="    
                                #       1234567890123456789SS1234567890123456789SS1234567890123    
                                #               Chinese Traditional  utilisateur@domaine  mot de passe    
                                #                            ユーザー@ドメイン    
     
                                ForEach($Item in $InputPromptTable)    
                                {    
                                        Line 3 ( "{0,-19}  {1,-19}  {2,-13}" -f     
                                                $Item.Language,     
                                                $Item.LoginHint,     
                                                $Item.PasswordHint    
                                        )    
                                }    
                                    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
     
                                ForEach($Item in $InputPromptTable)    
                                {    
                                        $rowdata += @(,(    
                                                $Item.Language,$htmlwhite,    
                                                $Item.LoginHint,$htmlwhite,    
                                                $Item.PasswordHint,$htmlwhite)    
                                        )    
                                }    
                                    
                                $columnHeaders = @(    
                                        "Language",($Script:htmlsb),    
                                        "Login hint",($Script:htmlsb),    
                                        "Pasword hint",($Script:htmlsb)    
                                )    
     
                                $msg = "User Portal (Web client)/Input prompt"    
                                $columnWidths = @("110","120","100")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "User Portal (Web client)/Secure Gateway"                                   WriteWordLine 4 0 "HTML5 client/Gateway"
 
                                Line 2 "User Portal (Web client)/Secure Gateway" <>                                 Line 2 "HTML5 client/Gateway"
 
                                $ScriptInformation.Add(@{Data = "Override Secure Gateway settings for theme"; Value = $Theme.UserPortal.Gateway.OverrideGatewaySettings.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Override gateway settings for theme"; Value = $Theme.HTML5Client.Gateway.OverrideGWSettings.ToString(); }) > $Null
 
                                $ScriptInformation.Add(@{Data = "     Launch sessions using"; Value = $ThemeUserPortalLaunchSessionsUsing; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "     Launch sessions using"; Value = $ThemeHTML5LaunchSessionsUsing; }) > $Null
                                Switch($Theme.UserPortal.Gateway.LaunchMethod)                                   Switch($Theme.HTML5Client.Gateway.LaunchMethod)
 
                                                $ScriptInformation.Add(@{Data = "     Allow user to select a launch method"; Value = $Theme.UserPortal.Gateway.AllowLaunchMethod.ToString(); }) > $Null <>                                                 $ScriptInformation.Add(@{Data = "     Allow user to select a launch method"; Value = $Theme.HTML5Client.Gateway.AllowLaunchMethod.ToString(); }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString(); }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString(); }) > $Null
 
                                                $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString(); }) > $Null <>                                                 $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString(); }) > $Null
 
                                $ScriptInformation.Add(@{Data = "     Use Pre Windows 2000 login format"; Value = $Theme.UserPortal.Gateway.Pre2000Cred.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "     Use Pre Windows 2000 login format"; Value = $Theme.HTML5Client.Gateway.Pre2000Cred.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "     Allow embedding of User Portal into other web pages"; Value = $Theme.UserPortal.Gateway.AllowEmbed.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow embedding of Parallels HTML5 Client into other web pages"; Value = $Theme.HTML5Client.Gateway.AllowEmbed.ToString(); }) > $Null
 
                                $ScriptInformation.Add(@{Data = "     Allow cross-origin resource sharing"; Value = $Theme.UserPortal.Gateway.AllowCORS.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "     Allow cross-origin resource sharing"; Value = $Theme.HTML5Client.Gateway.AllowCORS.ToString(); }) > $Null
                                If($Theme.UserPortal.Gateway.AllowCORS)                                   If($Theme.HTML5Client.Gateway.AllowCORS)
 
                                        ForEach($Domain in $Theme.UserPortal.Gateway.AllowedDomainsForCORS) <>                                         ForEach($Domain in $Theme.HTML5Client.Gateway.AllowedDomainsForCORS)
 
                                        $ScriptInformation.Add(@{Data = "Browser cache time"; Value = "$($Theme.UserPortal.Gateway.BrowserCacheTimeInMonths.ToString()) months"; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Browser cache time"; Value = "$($Theme.HTML5Client.Gateway.BrowserCacheTimeInMonths.ToString()) months"; }) > $Null
 
                                Line 3 "Override Secure Gateway settings for theme: " $Theme.UserPortal.Gateway.OverrideGatewaySettings.ToString() <>                                 Line 3 "Override gateway settings for theme: " $Theme.HTML5Client.Gateway.OverrideGWSettings.ToString()
 
                                Line 4 "Launch sessions using`t`t`t: " $ThemeUserPortalLaunchSessionsUsing <>                                 Line 4 "Launch sessions using`t`t`t: " $ThemeHTML5LaunchSessionsUsing
                                Switch($Theme.UserPortal.Gateway.LaunchMethod)                                   Switch($Theme.HTML5Client.Gateway.LaunchMethod)
 
                                                Line 4 "Allow user to select a launch method`t: " $Theme.UserPortal.Gateway.AllowLaunchMethod.ToString() <>                                                 Line 4 "Allow user to select a launch method`t: " $Theme.HTML5Client.Gateway.AllowLaunchMethod.ToString()
                                                Line 4 "Allow opening applications in a new tab`t: " $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString()                                                   Line 4 "Allow opening applications in a new tab`t: " $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString()
 
                                                Line 4 "Allow opening applications in a new tab`t: " $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString() <>                                                 Line 4 "Allow opening applications in a new tab`t: " $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString()
 
                                Line 4 "Use Pre Windows 2000 login format`t: " $Theme.UserPortal.Gateway.Pre2000Cred.ToString() <>                                 Line 4 "Use Pre Windows 2000 login format`t: " $Theme.HTML5Client.Gateway.Pre2000Cred.ToString()
                                Line 4 "Allow embedding of User Portal "                                   Line 4 "Allow embedding of Parallels HTML5 "
                                Line 4 "Client into other web pages`t`t: " $Theme.UserPortal.Gateway.AllowEmbed.ToString()                                   Line 4 "Client into other web pages`t`t: " $Theme.HTML5Client.Gateway.AllowEmbed.ToString()
 
                                Line 4 "Allow cross-origin resource sharing`t: " $Theme.UserPortal.Gateway.AllowCORS.ToString() <>                                 Line 4 "Allow cross-origin resource sharing`t: " $Theme.HTML5Client.Gateway.AllowCORS.ToString()
                                If($Theme.UserPortal.Gateway.AllowCORS)                                   If($Theme.HTML5Client.Gateway.AllowCORS)
 
                                        ForEach($Domain in $Theme.UserPortal.Gateway.AllowedDomainsForCORS) <>                                         ForEach($Domain in $Theme.HTML5Client.Gateway.AllowedDomainsForCORS)
 
                                        Line 5 "Browser cache time`t`t: "  "$($Theme.UserPortal.Gateway.BrowserCacheTimeInMonths.ToString()) months" <>                                         Line 5 "Browser cache time`t`t: "  "$($Theme.HTML5Client.Gateway.BrowserCacheTimeInMonths.ToString()) months"
 
                                $columnHeaders = @("Override Secure Gateway settings for theme",($Script:htmlsb),$Theme.UserPortal.Gateway.OverrideGatewaySettings.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Override gateway settings for theme",($Script:htmlsb),$Theme.HTML5Client.Gateway.OverrideGWSettings.ToString(),$htmlwhite)
 
                                $rowdata += @(,("     Launch sessions using",($Script:htmlsb),$ThemeUserPortalLaunchSessionsUsing,$htmlwhite)) <>                                 $rowdata += @(,("     Launch sessions using",($Script:htmlsb),$ThemeHTML5LaunchSessionsUsing,$htmlwhite))
                                Switch($Theme.UserPortal.Gateway.LaunchMethod)                                   Switch($Theme.HTML5Client.Gateway.LaunchMethod)
 
                                                $rowdata += @(,("     Allow user to select a launch method",($Script:htmlsb),$Theme.UserPortal.Gateway.AllowLaunchMethod.ToString(),$htmlwhite)) <>                                                 $rowdata += @(,("     Allow user to select a launch method",($Script:htmlsb),$Theme.HTML5Client.Gateway.AllowLaunchMethod.ToString(),$htmlwhite))
                                                $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb), $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString(),$htmlwhite))                                                   $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb), $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString(),$htmlwhite))
 
                                                $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb), $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString(),$htmlwhite)) <>                                                 $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb), $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString(),$htmlwhite))
 
                                $rowdata += @(,("     Use Pre Windows 2000 login format",($Script:htmlsb), $Theme.UserPortal.Gateway.Pre2000Cred.ToString(),$htmlwhite)) <>                                 $rowdata += @(,("     Use Pre Windows 2000 login format",($Script:htmlsb), $Theme.HTML5Client.Gateway.Pre2000Cred.ToString(),$htmlwhite))
                                $rowdata += @(,("     Allow embedding of User Portal into other web pages",($Script:htmlsb), $Theme.UserPortal.Gateway.AllowEmbed.ToString(),$htmlwhite))                                   $rowdata += @(,("     Allow embedding of Parallels HTML5 Client into other web pages",($Script:htmlsb), $Theme.HTML5Client.Gateway.AllowEmbed.ToString(),$htmlwhite))
 
                                $rowdata += @(,("     Allow cross-origin resource sharing",($Script:htmlsb),$Theme.UserPortal.Gateway.AllowCORS.ToString(),$htmlwhite)) <>                                 $rowdata += @(,("     Allow cross-origin resource sharing",($Script:htmlsb),$Theme.HTML5Client.Gateway.AllowCORS.ToString(),$htmlwhite))
                                If($Theme.UserPortal.Gateway.AllowCORS)                                   If($Theme.HTML5Client.Gateway.AllowCORS)
 
                                        ForEach($Domain in $Theme.UserPortal.Gateway.AllowedDomainsForCORS) <>                                         ForEach($Domain in $Theme.HTML5Client.Gateway.AllowedDomainsForCORS)
 
                                        $rowdata += @(,("Browser cache time",($Script:htmlsb),"$($Theme.UserPortal.Gateway.BrowserCacheTimeInMonths.ToString()) months",$htmlwhite)) <>                                         $rowdata += @(,("Browser cache time",($Script:htmlsb),"$($Theme.HTML5Client.Gateway.BrowserCacheTimeInMonths.ToString()) months",$htmlwhite))
 
                                $msg = "User Portal (Web client)/Secure Gateway" <>                                 $msg = "HTML5 client/Gateway"
 
                                WriteWordLine 4 0 "User Portal (Web client)/Legal policies" <>                                 WriteWordLine 4 0 "HTML5 client/Legal policies"
 
                                Line 2 "User Portal (Web client)/Legal policies" <>                                 Line 2 "HTML5 client/Legal policies"
 
                                $ScriptInformation.Add(@{Data = "     Enable cookie consent"; Value = $Theme.UserPortal.LegalPolicies.AllowCookieConsent.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "     Enable cookie consent"; Value = $Theme.HTML5Client.LegalPolicies.AllowCookieConsent.ToString(); }) > $Null
 
                                $ScriptInformation.Add(@{Data = "     Enable EULA"; Value = $Theme.UserPortal.LegalPolicies.AllowEULA.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "     Enable EULA"; Value = $Theme.HTML5Client.LegalPolicies.AllowEULA.ToString(); }) > $Null
 
                                Line 4 "Enable cookie consent`t: " $Theme.UserPortal.LegalPolicies.AllowCookieConsent.ToString() <>                                 Line 4 "Enable cookie consent`t: " $Theme.HTML5Client.LegalPolicies.AllowCookieConsent.ToString()
 
                                Line 4 "Enable EULA`t`t: " $Theme.UserPortal.LegalPolicies.AllowEULA.ToString() <>                                 Line 4 "Enable EULA`t`t: " $Theme.HTML5Client.LegalPolicies.AllowEULA.ToString()
 
                                $rowdata += @(,("     Enable cookie consent",($Script:htmlsb),$Theme.UserPortal.LegalPolicies.AllowCookieConsent.ToString(),$htmlwhite)) <>                                 $rowdata += @(,("     Enable cookie consent",($Script:htmlsb),$Theme.HTML5Client.LegalPolicies.AllowCookieConsent.ToString(),$htmlwhite))
 
                                $rowdata += @(,("     Enable EULA",($Script:htmlsb), $Theme.UserPortal.LegalPolicies.AllowEULA.ToString(),$htmlwhite)) <>                                 $rowdata += @(,("     Enable EULA",($Script:htmlsb), $Theme.HTML5Client.LegalPolicies.AllowEULA.ToString(),$htmlwhite))
 
                                $msg = "User Portal (Web client)/Legal policies" <>                                 $msg = "HTML5 client/Legal policies"
 
        If($MSWord -or $PDF) +-  
        {    
                WriteWordLine 2 0 "Certificates"    
        }    
        If($Text)    
        {    
                Line 1 "Certificates"    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 2 0 "Certificates"    
        }    
     
        Write-Verbose "$(Get-Date -Format G): Output Certificates"    
 
        No Certificates retrieved for Site $($Site.Name).` <>                 No Certificates retrieved for Site $($Site.Name).`
 
                ForEach($Cert in $Certs) <>                 If($MSWord -or $PDF)
 
  <>                         WriteWordLine 2 0 "Certificates"
                    }
                        Switch($Cert.Type)                   If($Text)
                        {                   {
                                "Imported"              {$CertType = "Imported"; Break}                           Line 1 "Certificates"
                                "LetsEncrypt"   {$CertType = "Let`'s Encrypt"; Break}    
                                "Request"               {$CertType = "Request"; Break}    
                                "SelfSigned"    {$CertType = "Sel-signed"; Break}    
                                Default                 {$CertType = "Unable to determine certificate type: $($Cert.Type)"; Break}    
                        }                   }
                                          If($HTML)
                        Switch($Cert.Usage)    
                        {                   {
                                "Gateway, HALB" {$CertUsage = "Secure Gateway, HALB "}                           WriteHTMLLine 2 0 "Certificates"
                                "Gateway"               {$CertUsage = "Secure Gateway "}    
                                "HALB"                  {$CertUsage = "HALB "}    
                                "None"                  {$CertUsage = "None "}    
                                Default                 {$CertUsage = "Unable to determine certificate usage: $($Cert.Usage)"; Break}    
                        }                   }
                            
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Certificates"
                    ForEach($Cert in $Certs)
                    {
 
                                $ScriptInformation.Add(@{Data = "Type"; Value = $CertType; }) > $Null +-  
 
                                $ScriptInformation.Add(@{Data = "Usage"; Value = $CertUsage; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Usage"; Value = $Cert.Usage; }) > $Null
 
                                Line 3 "Type`t`t`t: " $CertType +-  
 
                                Line 3 "Usage`t`t`t: " $CertUsage <>                                 Line 3 "Usage`t`t`t: " $Cert.Usage
 
                                $rowdata += @(,("Type",($Script:htmlsb),$CertType,$htmlwhite)) +-  
 
                                $rowdata += @(,("Usage",($Script:htmlsb),$CertUsage,$htmlwhite)) <>                                 $rowdata += @(,("Usage",($Script:htmlsb),$Cert.Usage,$htmlwhite))
 
                                "KeySize3072"           {$KeySize = "3072"; Break} <>  
                                "KeySize521"            {$KeySize = "521"; Break}    
                                "KeySizeUnknown"        {$KeySize = "Unknown"; Break}                                   "KeySizeUnknown"        {$KeySize = ""; Break}
 
                                $ScriptInformation.Add(@{Data = "Type"; Value = $CertType; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Status"; Value = $Cert.Status.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "State"; Value = $Cert.Status.ToString(); }) > $Null
 
                                Line 3 "Type`t`t`t: " $CertType <>  
                                Line 3 "Status`t`t`t: " $Cert.Status.ToString()                                   Line 3 "State`t`t`t: " $Cert.Status.ToString()
 
                                $rowdata += @(,("Type",($Script:htmlsb),$CertType,$htmlwhite)) <>  
                                $rowdata += @(,("Status",($Script:htmlsb),$Cert.Status.ToString(),$htmlwhite))                                   $rowdata += @(,("State",($Script:htmlsb),$Cert.Status.ToString(),$htmlwhite))
 
  <>         #Auditing - not in PoSH
     
            #Global logging - not in PoSH
     
            $FarmSettings = Get-RASFarmSettings -SiteId $Site.Id -ea 0 4>$Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Certificates for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Certificates for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $FarmSettings)
            {
                    Write-Host "
                    No Certificates retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Certificates retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Certificates retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Certificates retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
        If($MSWord -or $PDF)                   If($MSWord -or $PDF)
        {                   {
                WriteWordLine 2 0 "Settings"                           WriteWordLine 2 0 "Settings"
        }                   }
        If($Text)                   If($Text)
        {                   {
                Line 1 "Settings"                           Line 1 "Settings"
        }                   }
        If($HTML)                   If($HTML)
        {                   {
                WriteHTMLLine 2 0 "Settings"                           WriteHTMLLine 2 0 "Settings"
        }                   }
 
        Write-Verbose "$(Get-Date -Format G): Output Settings" <>                 Write-Verbose "$(Get-Date -Format G): `t`tOutput Settings"
        $FarmSettings = Get-RASFarmSettings -SiteId $Site.Id -ea 0 4>$Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Settings for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Settings for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Settings for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve Settings for Site $($Site.Name)"    
                }    
 
        ElseIf($? -and $Null -eq $FarmSettings) <>  
        {                   
                Write-Host "    
        No Settings retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)           If($MSWord -or $PDF)
                {    
                        WriteWordLine 0 0 "No Settings retrieved for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "No Settings retrieved for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Settings retrieved for Site $($Site.Name)"    
                }    
        }    
        Else    
 
        } <>  
            
        #Auditing - not in PoSH    
     
        #Global logging - not in PoSH    
     
        <#RASFarmSettings           
                Dropped Properties      ExcludeDirectRDP    
                                                        ExcludeDirectRDPForVDI    
                                                        SendHDIcons    
                                                        ReplicateSendHDIcons    
                                                        EnableOverlayIcons    
                                                        ShowPasswordExpiry    
                                                        ReplicateURLRedirection                   WriteWordLine 3 0 "URL redirection"
                                                        URLBlackList    
                                                        TokenValidationTime    
        #>    
        Write-Verbose "$(Get-Date -Format G): `tOutput URL redirection"    
            
        $URLRedirectionSettings = Get-RASURLRedirectionSettings -Siteid $Site.Id -EA 0 4> $Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve URL Redirection settings for Site $($Site.Name)`                   $ScriptInformation = New-Object System.Collections.ArrayList
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve URL Redirection settings for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve URL Redirection settings for Site $($Site.Name)"                   $ScriptInformation.Add(@{Data = "Do not redirect the following URLs"; Value = ""; }) > $Null
                }                   $cnt = -1
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve URL Redirection settings for Site $($Site.Name)"    
                }    
        }    
        ElseIf($? -and $Null -eq $URLRedirectionSettings)                   ForEach($Item in $FarmSettings.URLBlacklist)
        {                   {
                Write-Host "    
        No URL Redirection settings retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {                           $cnt++
                        WriteWordLine 0 0 "No URL Redirection settings retrieved for Site $($Site.Name)"    
                }                           
                If($Text)                           If($Cnt -eq 0)
                {                           {
                        Line 0 "No URL Redirection settings retrieved for Site $($Site.Name)"                                   $ScriptInformation.Add(@{Data = "     Url"; Value = $Item; }) > $Null
                }                           }
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No URL Redirection settings retrieved for Site $($Site.Name)"    
                }    
        }    
        Else                           Else
        {    
                If($URLRedirectionSettings.URLs.Count -eq 0)    
                {    
                        If($URLRedirectionSettings.DefaultAction -eq "Redirect")    
 
                                $URLAction = "Redirect" <>                                 $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
 
                        Else <>  
                        {    
                                $URLAction = "Do not redirect"    
                        }                   }
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 3 0 "URL redirection"    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "URL"; Value = "*"; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enabled"; Value = "True"; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Action"; Value = $URLAction; }) > $Null    
                                $ScriptInformation.Add(@{Data = "ID"; Value = "0"; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $URLRedirectionSettings.Replicate.ToString(); }) > $Null                   $ScriptInformation.Add(@{Data = "Settings are replicated to all Sitess"; Value = $FarmSettings.ReplicateURLRedirection.ToString(); }) > $Null
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                   -Columns Data,Value `
                                -List `                   -List `
                                -Format $wdTableGrid `                   -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                   -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                 $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                   $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                 FindWordDocumentEnd
                                $Table = $Null                   $Table = $Null
                                WriteWordLine 0 0 ""                   WriteWordLine 0 0 ""
                        }           }
                        If($Text)           If($Text)
                        {           {
                                Line 2 "URL redirection"                   Line 2 "URL redirection"
                                Line 3 "URL: " "*"    
                                Line 3 "Enabled: " "True"    
                                Line 3 "Action: " $URLAction    
                                Line 3 "ID: " "0"    
                                Line 3 "Settings are replicated to all Sites: " $URLRedirectionSettings.Replicate.ToString()    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 3 0 "URL redirection"                   Line 3 "Do not redirect the following URLs`t: "
                                $rowdata = @()    
                                $columnHeaders = @("URL",($Script:htmlsb),"*",$htmlwhite)    
                                $rowdata += @(,("URL",($Script:htmlsb), "*",$htmlwhite))    
                                $rowdata += @(,("Enabled",($Script:htmlsb), "True",$htmlwhite))    
                                $rowdata += @(,("Action",($Script:htmlsb), $URLAction,$htmlwhite))    
                                $rowdata += @(,("ID",($Script:htmlsb), "0",$htmlwhite))    
                                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb), $URLRedirectionSettings.Replicate.ToString(),$htmlwhite))    
                    $cnt = -1
                                $msg = ""    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
     
                                WriteHTMLLine 0 0 ""    
                        }    
                }    
                Else    
                {    
                        If($URLRedirectionSettings.DefaultAction -eq "Redirect")                   ForEach($Item in $FarmSettings.URLBlacklist)
                        {                   {
                                $URLAction = "Redirect"    
                        }    
                        Else    
                        {    
                                $URLAction = "Do not redirect"    
                        }    
                            $cnt++
                        $URLList = New-Object System.Collections.ArrayList    
 
                        $obj = [PSCustomObject]@{        <>                         If($Cnt -eq 0)
                                URL      = "*"    
                                Enabled  = "True"    
                                Priority = "4294967295"    
                                Action   = $URLAction    
                                ID       = "0"    
                        }                           
                        $Null = $URLList.Add($obj)    
                            
                        ForEach($item in $URLRedirectionSettings.URLs)    
 
                                $Result = Get-RASURLRedirectionEntry -Siteid $Site.Id -Id $item.Id -EA 0 4> $Null <>  
                                    
                                If($item.Action -eq "Redirect")    
                                {    
                                        $URLAction = "Redirect"                                   Line 7 "     Url: " $Item
                                }                           }
                                Else                           Else
                                {    
                                        $URLAction = "Do not redirect"    
                                }    
     
                                $obj = [PSCustomObject]@{           
                                        URL      = $item.URL    
                                        Enabled  = $item.Enabled.ToString()    
                                        Priority = $item.Priority.ToString()    
                                        Action   = $URLAction    
                                        ID       = $item.Id.ToString()    
                                }                           
                                $Null = $URLList.Add($obj)    
                        }    
                            
                        $URLList = $URLList | Sort-Object Priority    
                            
                        If($MSWord -or $PDF)    
 
                                [System.Collections.Hashtable[]] $URLListWordTable = @(); <>  
                                ForEach($URL in $URLList)    
                                {    
                                        $URLListWordTable += @{    
                                                URL      = $URL.URL;    
                                                Enabled  = $URL.Enabled;    
                                                Priority = $URL.Priority;    
                                                Action   = $URL.Action;    
                                                ID       = $URL.Id;    
                                        }                                                   
                                }    
                                    
                                WriteWordLine 3 0 "URL redirection"    
                                $Table = AddWordTable -Hashtable $URLListWordTable `    
                                -Columns URL, Enabled, Action, ID `    
                                -Headers "URL", "Enabled", "Action", "ID" `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 250;    
                                $Table.Columns.Item(2).Width = 50;    
                                $Table.Columns.Item(3).Width = 100;    
                                $Table.Columns.Item(4).Width = 50;    
                                    
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""                                   Line 8 "  " $Item
     
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $URLRedirectionSettings.Replicate.ToString(); }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 250;    
                                $Table.Columns.Item(2).Width = 50;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
 
                        If($Text) <>  
                        {    
                                Line 2 "URL redirection"    
                                Line 0 ""    
                                Line 2 "URL                                                 Enabled  Action           ID "    
                                Line 2 "================================================================================="    
                                #               https://www.somereallylongurl.com/somelongsitename  False    Do not redirect  999    
                                #               12345678901234567890123456789012345678901234567890SS1234567SS123456789012345SS123    
                                ForEach($item in $URLList)    
                                {    
                                        Line 2 ( "{0,-50}  {1,-7}  {2,-15}  {3,-3}" -f $item.URL, $item.Enabled, $item.Action, $item.ID)    
                                }                   }
                                Line 0 ""    
                                Line 2 "Settings are replicated to all Sites: " $URLRedirectionSettings.Replicate.ToString()                   Line 3 "Settings are replicated to all Sites`t: " $FarmSettings.ReplicateURLRedirection.ToString()
                                Line 0 ""                   Line 0 ""
                        }           }
                        If($HTML)           If($HTML)
                        {           {
                                WriteHTMLLine 3 0 "URL redirection"                   WriteHTMLLine 3 0 "URL redirection"
                                $rowdata = @()                   $rowdata = @()
                    $columnHeaders = @("Do not redirect the following URLs",($Script:htmlsb),"",$htmlwhite)
                    $cnt = -1
                                ForEach($item in $URLList)                   ForEach($Item in $FarmSettings.URLBlacklist)
                                {                   {
                                        $rowdata += @(,(                           $cnt++
                                                $item.URL,$htmlwhite,                          
                                                $item.Enabled,$htmlwhite,                           If($Cnt -eq 0)
                                                $item.Action,$htmlwhite,    
                                                $item.ID,$htmlwhite    
                                                ))                           {
                                    $rowdata += @(,("     URL",($Script:htmlsb),$Item,$htmlwhite))
                                }                           }
                            Else
                            {
                                $columnHeaders = @(    
                                "URL",($Script:htmlsb),    
                                "Enabled",($Script:htmlsb),                                   $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                "Action",($Script:htmlsb),    
                                "ID",($Script:htmlsb))    
                            }
                                $msg = ""    
                                $columnWidths = @("250","50","100","50")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                    }
                                $rowdata = @()    
                                $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$URLRedirectionSettings.Replicate.ToString(),$htmlwhite)                   $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FarmSettings.ReplicateURLRedirection.ToString(),$htmlwhite))
 
                                $msg = "" <>                 $msg = ""
                                $columnWidths = @("250","50")                   $columnWidths = @("200","275")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
 
                                WriteHTMLLine 0 0 "" <>                 WriteHTMLLine 0 0 ""
                        }    
                }    
 
  <>                 
     
 
        <>                 
        $RASClientSettings = Get-RASClientSettings -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve CLient Settings information    
                "    
                If($MSWord -or $PDF)           If($MSWord -or $PDF)
                {           {
                        WriteWordLine 0 0 "Unable to retrieve CLient Settings information"                   WriteWordLine 3 0 "Client settings"
                }                   $ScriptInformation = New-Object System.Collections.ArrayList
                If($Text)                   If($FarmSettings.SendHDIcons)
 
                        Line 0 "Unable to retrieve CLient Settings information" <>                         $ScriptInformation.Add(@{Data = "Published application icons"; Value = "Send high resolution icons (uses more network bandwidth)"; }) > $Null
 
                If($HTML) <>                 Else
 
                        WriteHTMLLine 0 0 "Unable to retrieve CLient Settings information" <>                         $ScriptInformation.Add(@{Data = "Published application icons"; Value = "Send standard resolution icons"; }) > $Null
 
  -+                 $ScriptInformation.Add(@{Data = "Enable overlay icon"; Value = $FarmSettings.EnableOverlayIcons.ToString(); }) > $Null
                    $ScriptInformation.Add(@{Data = "Show password expiration reminder"; Value = $FarmSettings.ShowPasswordExpiry.ToString(); }) > $Null
                    $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FarmSettings.ReplicateSendHDIcons.ToString(); }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 200;
                    $Table.Columns.Item(2).Width = 250;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
     
                    WriteWordLine 0 0 ""
 
        ElseIf($? -and $null -eq $RASClientSettings) <>         If($Text)
 
                Write-Host " <>  
                No CLient Settings information was found                   Line 2 "Client settings"
                " -ForegroundColor White                   If($FarmSettings.SendHDIcons)
                If($MSWord -or $PDF)    
 
                        WriteWordLine 0 0 "No CLient Settings information was found" <>                         Line 3 "Published application icons`t`t: " "Send high resolution icons (uses more network bandwidth)" ""
 
                If($Text) <>                 Else
 
                        Line 0 "No CLient Settings information was found" <>                         Line 3 "Published application icons`t`t: " "Send standard resolution icons" ""
 
  <>                 Line 3 "Enable overlay icon`t`t`t: " $FarmSettings.EnableOverlayIcons.ToString()
                    Line 3 "Show password expiration reminder`t: " $FarmSettings.ShowPasswordExpiry.ToString()
                    Line 3 "Settings are replicated to all Sites`t: " $FarmSettings.ReplicateSendHDIcons.ToString()
                    Line 0 ""
            }
                If($HTML)           If($HTML)
                {           {
                        WriteHTMLLine 0 0 "No CLient Settings information was found"                   WriteHTMLLine 3 0 "Client settings"
                    $rowdata = @()
                    If($FarmSettings.SendHDIcons)
                }                   {
                            $columnHeaders = @("Published application icons",($Script:htmlsb),"Send high resolution icons (uses more network bandwidth)",$htmlwhite)
        }                   }
        Else                   Else
        {                   {
                OutputRASClientSettings $RASClientSettings                           $columnHeaders = @("Published application icons",($Script:htmlsb),"Send standard resolution icons",$htmlwhite)
                    }
                    $rowdata += @(,("Enable overlay icon",($Script:htmlsb),$FarmSettings.EnableOverlayIcons.ToString(),$htmlwhite))
                    $rowdata += @(,("Show password expiration reminder",($Script:htmlsb),$FarmSettings.ShowPasswordExpiry.ToString(),$htmlwhite))
                    $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FarmSettings.ReplicateSendHDIcons.ToString(),$htmlwhite))
     
                    $msg = ""
                    $columnWidths = @("200","275")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
     
                    WriteHTMLLine 0 0 ""
 
                #$FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate <>                 $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
 
  -+                         WriteWordLine 4 0 "FSLogix"
 
                        $ScriptInformation.Add(@{Data = "FSLogix"; Value = ""; }) > $Null <>  
                        $ScriptInformation.Add(@{Data = "     Deployment method"; Value = $FSLogixDeploymentSettingsDeploymentMethod; }) > $Null                           $ScriptInformation.Add(@{Data = "Deployment method"; Value = $FSLogixDeploymentSettingsDeploymentMethod; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "     URL"; Value = $FSLogixDeploymentSettingsInstallOnlineURL; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "URL"; Value = $FSLogixDeploymentSettingsInstallOnlineURL; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "     Install from a network share"; Value = $FSLogixDeploymentSettingsNetworkDrivePath; }) > $Null <>                                 $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsNetworkDrivePath; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "     Push from a Connection Broker"; Value = $FSLogixDeploymentSettingsInstallerFileName; }) > $Null <>                                 $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsInstallerFileName; }) > $Null
 
                        #not available yet <>  
                        #$ScriptInformation.Add(@{Data = "Azure Virtual Desktop"; Value = ""; }) > $Null    
                        #$ScriptInformation.Add(@{Data = "     Enable Azure Virtual Desktop management"; Value = "Can't find"; }) > $Null    
                        #$ScriptInformation.Add(@{Data = "     Client feature set"; Value = "Can't find"; }) > $Null    
                        #$ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null                           $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null
 
                        Line 4 "Deployment method`t`t`t: " $FSLogixDeploymentSettingsDeploymentMethod <>                         Line 4 "Deployment method`t`t`t`t`t: " $FSLogixDeploymentSettingsDeploymentMethod
 
                                Line 4 "URL`t`t`t`t`t: " $FSLogixDeploymentSettingsInstallOnlineURL <>                                 Line 4 "URL`t`t`t`t`t`t`t: " $FSLogixDeploymentSettingsInstallOnlineURL
 
                                Line 4 "Install from a network share`t`t: " $FSLogixDeploymentSettingsNetworkDrivePath <>                                 Line 11 ": " $FSLogixDeploymentSettingsNetworkDrivePath
 
                                Line 4 "Push from a Connection Broker`t`t: " $FSLogixDeploymentSettingsInstallerFileName <>                                 Line 11 ": " $FSLogixDeploymentSettingsInstallerFileName
 
                        #not available yet <>  
                        #Line 3 "Azure Virtual Desktop"    
                        #Line 4 "Enable Azure Virtual Desktop management`t: " "Can't find"    
                        #Line 4 "Client feature set`t`t`t: " "Can't find"    
                        #Line 3 "Settings are replicated to all Sites`t`t: " $FSLogixDeploymentSettingsReplicate.ToString()                           Line 4 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString()
                        Line 0 ""    
 
                        $columnHeaders = @("FSLogix",($Script:htmlsb),"",$htmlwhite) <>  
                        $rowdata += @(,("     Deployment method",($Script:htmlsb),$FSLogixDeploymentSettingsDeploymentMethod,$htmlwhite))                           $columnHeaders = @("Deployment method",($Script:htmlsb),$FSLogixDeploymentSettingsDeploymentMethod,$htmlwhite)
 
                                $rowdata += @(,("     URL",($Script:htmlsb),$FSLogixDeploymentSettingsInstallOnlineURL,$htmlwhite)) <>                                 $rowdata += @(,("URL",($Script:htmlsb),$FSLogixDeploymentSettingsInstallOnlineURL,$htmlwhite))
 
                                $rowdata += @(,("     Install from a network share",($Script:htmlsb),$FSLogixDeploymentSettingsNetworkDrivePath,$htmlwhite)) <>                                 $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsNetworkDrivePath,$htmlwhite))
 
                                $rowdata += @(,("     Push from a Connection Broker",($Script:htmlsb),$FSLogixDeploymentSettingsInstallerFileName,$htmlwhite)) <>                                 $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsInstallerFileName,$htmlwhite))
 
                        #not available yet <>  
                        #$rowdata += @(,("Azure Virtual Desktop",($Script:htmlsb),"",$htmlwhite))    
                        #$rowdata += @(,("     Enable Azure Virtual Desktop management",($Script:htmlsb),"Can't find",$htmlwhite))    
                        #$rowdata += @(,("     Client feature set",($Script:htmlsb),"Can't find",$htmlwhite))    
                        #$rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite))                           $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite))
 
                        $msg = "" <>                         $msg = "FSLogix"
                        $columnWidths = @("250","225")                           $columnWidths = @("200","250")
 
        WVDApp and AVDApp <>         WVDApp
        WVDDesktop and AVDDesktop           WVDDesktop
 
  -+                 If($PubItem.PreferredRoutingEnabled)
                    {
                            $Results = Get-RASPubItemPreferredRoute -Id $PubItem.Id -EA 0 4> $Null
                            
                            If(!$? -or $Null -eq $Results)
                            {
                                    $PreferredRouting = ""
                            }
                            Else
                            {
                                    $PreferredRouting = ""
                            }
                    }
                    Else
                    {
                            $PreRouting = ""
                    }
                    
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null
                                            }
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null
 
                                If($PubItem.PreferredRoutingEnabled) +-  
                                {    
                                        $Results = Get-RASPubItemPreferredRoute -Id $PubItem.Id -EA 0 4> $Null    
                                            
                                        If($? -and $Null -ne $Results)    
                                        {    
                                                $cnt =-1    
                                                ForEach($PrefRoute in $Results)    
                                                {    
                                                        $CustomRoute = Get-RASCustomRoute -Id $PrefRoute.Id -EA 0 4>$Null    
                                                            
                                                        If($? -and $Null -ne $CustomRoute)    
                                                        {    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = "Preferred routing is enabled"; Value = ""; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)"; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)"; }) > $Null    
                                                                }    
                                                        }    
                                                }    
                                        }    
                                }    
                    
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                Line 10 "  Chrome OS" <>                                                 Line 10 "  ChromeApp"
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    Line 10 "  HTML5"
                                            }
                                            
 
                                                Line 10 "  iOS/iPadOS" <>                                                 Line 10 "  iOS"
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                        } +-  
                                }    
     
                                If($PubItem.PreferredRoutingEnabled)    
                                {    
                                        $Results = Get-RASPubItemPreferredRoute -Id $PubItem.Id -EA 0 4> $Null    
                                            
                                        If($? -and $Null -ne $Results)    
                                        {    
                                                $cnt =-1    
                                                ForEach($PrefRoute in $Results)    
                                                {    
                                                        $CustomRoute = Get-RASCustomRoute -Id $PrefRoute.Id -EA 0 4>$Null    
                                                            
                                                        If($? -and $Null -ne $CustomRoute)    
                                                        {    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        Line 3 "Preferred routing is enabled"    
                                                                        Line 7 "$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)"    
                                                                }    
                                                                Else    
                                                                {    
                                                                        Line 7 "$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)"    
                                                                }    
                                                        }    
                                                }    
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))
                                            }
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))
 
                                If($PubItem.PreferredRoutingEnabled) +-  
                                {    
                                        $Results = Get-RASPubItemPreferredRoute -Id $PubItem.Id -EA 0 4> $Null    
                                            
                                        If($? -and $Null -ne $Results)    
                                        {    
                                                $cnt =-1    
                                                ForEach($PrefRoute in $Results)    
                                                {    
                                                        $CustomRoute = Get-RASCustomRoute -Id $PrefRoute.Id -EA 0 4>$Null    
                                                            
                                                        If($? -and $Null -ne $CustomRoute)    
                                                        {    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $rowdata += @(,("Preferred routing is enabled",($Script:htmlsb),"",$htmlwhite))    
                                                                        $rowdata += @(,("",($Script:htmlsb),"$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)",$htmlwhite))    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $rowdata += @(,("",($Script:htmlsb),"$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)",$htmlwhite))    
                                                                }    
                                                        }    
                                                }    
                                        }    
                                }    
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null
                                            }
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                Line 10 "  Chrome OS" <>                                                 Line 10 "  ChromeApp"
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    Line 10 "  HTML5"
                                            }
                                            
 
                                                Line 10 "  iOS/iPadOS" <>                                                 Line 10 "  iOS"
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))
                                            }
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null
                                            }
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                Line 10 "  Chrome OS" <>                                                 Line 10 "  ChromeApp"
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    Line 10 "  HTML5"
                                            }
                                            
 
                                                Line 10 "  iOS/iPadOS" <>                                                 Line 10 "  iOS"
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))
                                            }
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null
                                            }
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                Line 10 "  Chrome OS" <>                                                 Line 10 "  ChromeApp"
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    Line 10 "  HTML5"
                                            }
                                            
 
                                                Line 10 "  iOS/iPadOS" <>                                                 Line 10 "  iOS"
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))
                                            }
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null
                                            }
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                Line 10 "  Chrome OS" <>                                                 Line 10 "  ChromeApp"
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    Line 10 "  HTML5"
                                            }
                                            
 
                                                Line 10 "  iOS/iPadOS" <>                                                 Line 10 "  iOS"
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))
                                            }
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null
                                            }
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                Line 10 "  Chrome OS" <>                                                 Line 10 "  ChromeApp"
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    Line 10 "  HTML5"
                                            }
                                            
 
                                                Line 10 "  iOS/iPadOS" <>                                                 Line 10 "  iOS"
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))
                                            }
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null
                                            }
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                Line 10 "  Chrome OS" <>                                                 Line 10 "  ChromeApp"
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    Line 10 "  HTML5"
                                            }
                                            
 
                                                Line 10 "  iOS/iPadOS" <>                                                 Line 10 "  iOS"
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))
                                            }
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))
 
                ElseIf($PubItem.Type -eq "WVDApp" -or ($PubItem.Type -eq "AVDApp") <>                 ElseIf($PubItem.Type -eq "WVDApp")
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null
                                            }
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                Line 10 "  Chrome OS" <>                                                 Line 10 "  ChromeApp"
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    Line 10 "  HTML5"
                                            }
                                            
 
                                                Line 10 "  iOS/iPadOS" <>                                                 Line 10 "  iOS"
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))
                                            }
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))
 
                ElseIf($PubItem.Type -eq "WVDDesktop" -or $PubItem.Type -eq "AVDDesktop") <>                 ElseIf($PubItem.Type -eq "WVDDesktop")
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null
                                            }
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                Line 10 "  Chrome OS" <>                                                 Line 10 "  ChromeApp"
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    Line 10 "  HTML5"
                                            }
                                            
 
                                                Line 10 "  iOS/iPadOS" <>                                                 Line 10 "  iOS"
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                   $PubItem.GatewayFilterEnabled -or  <>                                    $PubItem.GWFilterEnabled -or 
 
                                If($PubItem.GatewayFilterEnabled) <>                                 If($PubItem.GWFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGateways) <>                                         ForEach($item in $PubItem.AllowedGWs)
 
                                                $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))
 
  -+                                         If($PubItem.AllowedOSes.HTML5)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))
                                            }
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.WebClient) <>                                         If($PubItem.AllowedOSes.WebPortal)
 
                                                $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))
 
  -+  
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.UserFilterReplicate.ToString(); }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 100;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
 
  -+  
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ClientFilterReplicate.ToString(); }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 100;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
 
                                $ScriptInformation.Add(@{Data = "Chrome OS"; Value = "Enabled"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "ChromeApp"; Value = "Enabled"; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Chrome OS"; Value = "Disabled"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "ChromeApp"; Value = "Disabled"; }) > $Null
 
  -+                         If($PubItem.AllowedOSes.HTML5)
                            {
                                    $ScriptInformation.Add(@{Data = "HTML5"; Value = "Enabled"; }) > $Null
                            }
                            Else
                            {
                                    $ScriptInformation.Add(@{Data = "HTML5"; Value = "Disabled"; }) > $Null
                            }
                            
 
                                $ScriptInformation.Add(@{Data = "iOS/iPadOS"; Value = "Enabled"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "iOS"; Value = "Enabled"; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "iOS/iPadOS"; Value = "Disabled"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "iOS"; Value = "Disabled"; }) > $Null
 
                        If($PubItem.AllowedOSes.WebClient) <>                         If($PubItem.AllowedOSes.WebPortal)
 
                                $ScriptInformation.Add(@{Data = "User Portal (Web Client)"; Value = "Enabled"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "RAS Web Portal"; Value = "Enabled"; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "User Portal (Web Client)"; Value = "Disabled"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "RAS Web Portal"; Value = "Disabled"; }) > $Null
 
  -+  
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
     
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.OSFilterReplicate.ToString(); }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 100;
 
  -+  
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.IPFilterReplicate.ToString(); }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 100;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
 
  -+  
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.MACFilterReplicate.ToString(); }) > $Null
     
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 100;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
 
                If(!($PubItem.GatewayFilterEnabled)) <>                 If(!($PubItem.GWFilterEnabled))
 
                        ForEach($item in $PubItem.AllowedGateways) <>                         ForEach($item in $PubItem.AllowedGWs)
 
                        If($PubItem.AllowedUsers.Count -gt 0) <>  
                        {    
                                Line 0 ""                           Line 0 ""
                                                          
                                $maxLength = ($PubItem.AllowedUsers.Account | Measure-Object -Property length -Maximum).Maximum                           $maxLength = ($PubItem.AllowedUsers.Account | Measure-Object -Property length -Maximum).Maximum
                                $NegativeMaxLength = $maxLength * -1                           $NegativeMaxLength = $maxLength * -1
                                Line 3 "User" -nonewline                           Line 3 "User" -nonewline
                                Line 0 (" " * ($maxLength - 3)) -nonewline                           Line 0 (" " * ($maxLength - 3)) -nonewline
                                LIne 0 "Type  SID"                           LIne 0 "Type  SID"
                                Line 3 ("=" * ($maxLength + 1 + 6 + 45)) # $maxLength, space, "Type" plus 2 spaces, length of SID                           Line 3 ("=" * ($maxLength + 1 + 6 + 45)) # $maxLength, space, "Type" plus 2 spaces, length of SID
                                ForEach($item in $PubItem.AllowedUsers)                           ForEach($item in $PubItem.AllowedUsers)
                                {                           {
                                        Line 3 ("{0,$NegativeMaxLength} {1,-5} {2,-45}" -f $item.Account,$item.Type,$item.Sid)                                   Line 3 ("{0,$NegativeMaxLength} {1,-5} {2,-45}" -f $item.Account,$item.Type,$item.Sid)
                                }                           }
                        }                           Line 0 ""
                        Else    
                        {    
                                Line 0 "There are no users configured"                           Line 3 "Settings are replicated to all Sites: " $PubItem.UserFilterReplicate.ToString()
                        }    
 
  -+                         Line 0 ""
     
                            Line 3 "Settings are replicated to all Sites: " $PubItem.ClientFilterReplicate.ToString()
 
                                Line 3 "Chrome OS`t: " "Enabled" <>                                 Line 3 "ChromeApp`t: " "Enabled"
 
                                Line 3 "Chrome OS`t: " "Disabled" <>                                 Line 3 "ChromeApp`t: " "Disabled"
                            }
                            
                            If($PubItem.AllowedOSes.HTML5)
                            {
                                    Line 3 "HTML5`t`t: " "Enabled"
                            }
                            Else
                            {
                                    Line 3 "HTML5`t`t: " "Disabled"
 
                        If($PubItem.AllowedOSes.WebClient) <>                         If($PubItem.AllowedOSes.WebPortal)
 
  -+                         Line 0 ""
     
                            Line 3 "Settings are replicated to all Sites: " $PubItem.OSFilterReplicate.ToString()
 
  -+  
                            Line 3 "Settings are replicated to all Sites: " $PubItem.IPFilterReplicate.ToString()
                            Line 0 ""
 
  -+  
                            Line 3 "Settings are replicated to all Sites: " $PubItem.MACFilterReplicate.ToString()
                            Line 0 ""
 
                If(!($PubItem.GatewayFilterEnabled)) <>                 If(!($PubItem.GWFilterEnabled))
 
                        ForEach($item in $PubItem.AllowedGateways) <>                         ForEach($item in $PubItem.AllowedGWs)
 
  -+  
                            $rowdata = @()
                            $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.UserFilterReplicate.ToString(),$htmlwhite)
     
                            $msg = ""
                            $columnWidths = @("183","100")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
 
  -+                         WriteHTMLLine 0 0 ""
     
                            $rowdata = @()
                            $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.ClientFilterReplicate.ToString(),$htmlwhite)
     
                            $msg = ""
                            $columnWidths = @("183","100")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
 
                                $rowdata += @(,("Chrome OS",($Script:htmlsb),"Enabled",$htmlwhite)) <>                                 $rowdata += @(,("ChromeApp",($Script:htmlsb),"Enabled",$htmlwhite))
 
                                $rowdata += @(,("Chrome OS",($Script:htmlsb),"Disabled",$htmlwhite)) <>                                 $rowdata += @(,("ChromeApp",($Script:htmlsb),"Disabled",$htmlwhite))
 
  -+                         If($PubItem.AllowedOSes.HTML5)
                            {
                                    $rowdata += @(,("HTML5",($Script:htmlsb),"Enabled",$htmlwhite))
                            }
                            Else
                            {
                                    $rowdata += @(,("HTML5",($Script:htmlsb),"Disabled",$htmlwhite))
                            }
                            
 
                                $rowdata += @(,("iOS/iPadOS",($Script:htmlsb),"Enabled",$htmlwhite)) <>                                 $rowdata += @(,("iOS",($Script:htmlsb),"Enabled",$htmlwhite))
 
                                $rowdata += @(,("iOS/iPadOS",($Script:htmlsb),"Disabled",$htmlwhite)) <>                                 $rowdata += @(,("iOS",($Script:htmlsb),"Disabled",$htmlwhite))
 
                        If($PubItem.AllowedOSes.WebClient) <>                         If($PubItem.AllowedOSes.WebPortal)
 
                                $rowdata += @(,("User Portal (Web Client)",($Script:htmlsb),"Enabled",$htmlwhite)) <>                                 $rowdata += @(,("RAS Web Portal",($Script:htmlsb),"Enabled",$htmlwhite))
 
                                $rowdata += @(,("User Portal (Web Client)",($Script:htmlsb),"Disabled",$htmlwhite)) <>                                 $rowdata += @(,("RAS Web Portal",($Script:htmlsb),"Disabled",$htmlwhite))
 
  -+                         WriteHTMLLine 0 0 ""
     
                            $rowdata = @()
                            $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.OSFilterReplicate.ToString(),$htmlwhite)
     
                            $msg = ""
                            $columnWidths = @("183","100")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
 
  -+  
                            $rowdata = @()
                            $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.IPFilterReplicate.ToString(),$htmlwhite)
     
                            $msg = ""
                            $columnWidths = @("183","100")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
 
  -+  
                            $rowdata = @()
                            $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.MACFilterReplicate.ToString(),$htmlwhite)
     
                            $msg = ""
                            $columnWidths = @("183","100")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
 
                If(!($PubItem.GatewayFilterEnabled)) <>                 If(!($PubItem.GWFilterEnabled))
 
                        ForEach($item in $PubItem.AllowedGateways) <>                         ForEach($item in $PubItem.AllowedGWs)
 
                $RDSObjects     = New-Object System.Collections.ArrayList +-  
                $VDIHostObjects = New-Object System.Collections.ArrayList    
     
 
                        $RDSobjects = [PSCustomObject] @{ <>                         $RDSobj = [PSCustomObject] @{
                                Server        = "None found"                                   Server = "None found"
                                Type          = "N/A"                                   Type = "N/A"
 
                        $RDSobjects = [PSCustomObject] @{ <>                         $RDSobj = [PSCustomObject] @{
                                Server        = "None found"                                   Server = "None found"
                                Type          = "N/A"                                   Type = "N/A"
 
                        ForEach($Result in $Results) <>  
                        {    
                                If($Result.EnablePrinting)    
                                {    
                                        $State = "Enabled"    
                                }    
                                Else    
                                {    
                                        $State = "Disabled"    
                                }    
                                    
                                $RDSobj = [PSCustomObject] @{                           $RDSobj = [PSCustomObject] @{
                                        Server        = $Result.Server                                   Server = $Results.Server
                                        Type          = "RD Session Hosts"                                   Type = "RD Session Hosts"
                                        PrintingState = $State                                   PrintingState = $Results.EnablePrinting
                                }    
                                $Null = $RDSObjects.Add($RDSobj)    
                }                           }
 
                        $VDIHostobjects = [PSCustomObject] @{ <>                         $VDIHostsobj = [PSCustomObject] @{
                                Server        = "Unable to retrieve"                                   Server = "Unable to retrieve"
                                Type          = "N/A"                                   Type = "N/A"
 
                        $VDIHostobjects = [PSCustomObject] @{ <>                         $VDIHostsobj = [PSCustomObject] @{
                                Server        = "None found"                                   Server = "None found"
                                Type          = "N/A"                                   Type = "N/A"
 
                        ForEach($Result in $Results) <>  
                        {    
                                If($Result.EnablePrinting)    
                                {    
                                        $State = "Enabled"    
                                }    
                                Else    
                                {    
                                        $State = "Disabled"    
                                }    
                                    
                                $VDIHostsobj = [PSCustomObject] @{                           $VDIHostsobj = [PSCustomObject] @{
                                        Server        = $Result.Server                                   Server = $Results.Server
                                        Type          = "VDI Providers"                                   Type = "VDI Providers"
                                        PrintingState = $State                                   PrintingState = $Results.EnablePrinting
                                }    
                                $Null = $VDIHostObjects.Add($VDIHostsobj)    
 
                OutputUniversalPrintingSettings $Printingobj $RDSobjects $VDIHostobjects <>                 OutputUniversalPrintingSettings $Printingobj $RDSobj $VDIHostsobj
 
  -+         Switch ($RDSobj.PrintingState)
            {
                    $True   {$RDSPrintingState = "Enabled"; Break}
                    $False  {$RDSPrintingState = "Disabled"; Break}
                    "N/A"   {$RDSPrintingState = "N/A"; Break}
                    Default {$RDSPrintingState = "Unable to determine RD Sessions Hosts Printing State: $($RDSobj.PrintingState)"; Break}
            }
            
            Switch ($VDIHostsobj.PrintingState)
            {
                    $True   {$VDIHostsPrintingState = "Enabled"; Break}
                    $False  {$VDIHostsPrintingState = "Disabled"; Break}
                    "N/A"   {$VDIHostsPrintingState = "N/A"; Break}
                    Default {$VDIHostsPrintingState = "Unable to determine VDI Hosts Printing State: $($VDIHostsobj.PrintingState)"; Break}
            }
     
            $RDSType = $RDSObj.Type
            $VDIType = $VDIHostsObj.Type
            
 
                ForEach($obj in $RDSobj) <>                 ForEach($RDSServer in $RDSobj.Server)
 
                                Server = $obj.Server <>                                 Server = $RDSServer
                                Type   = $obj.Type                                   Type   = $RDSType
                                State  = $obj.PrintingState                                   State  = $RDSPrintingState
 
        <>                 
                ForEach($obj in $VDIHostsobj)                   ForEach($VDIServer in $VDIHostsobj.Server)
 
                                Server = $obj.Server <>                                 Server = $VDIServer
                                Type   = $obj.Type                                   Type   = $VDIType
                                State  = $obj.PrintingState                                   State  = $VDIHostsPrintingState
 
  -+                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
 
                ForEach($obj in $RDSobj) <>                 ForEach($RDSServer in $RDSobj.Server)
 
                                $obj.Server,  <>                                 $RDSServer, 
                                $obj.Type,                                    $RDSType, 
                                $obj.PrintingState                                   $RDSPrintingState
 
        <>                 
                ForEach($obj in $VDIHostsobj)                   ForEach($VDIServer in $VDIHostsobj.Server)
 
                                $obj.Server,  <>                                 $VDIServer, 
                                $obj.Type,                                    $VDIType, 
                                $obj.PrintingState                                   $VDIHostsPrintingState
 
  +-  
 
                ForEach($obj in $RDSobj) <>                 ForEach($RDSServer in $RDSobj.Server)
 
                                $obj.Server,$htmlwhite, <>                                 $RDSServer,$htmlwhite,
                                $obj.Type,$htmlwhite,                                   $RDSType,$htmlwhite,
                                $obj.PrintingState,$htmlwhite)                                   $RDSPrintingState,$htmlwhite)
 
  <>                 
                ForEach($obj in $VDIHostsobj)                   ForEach($VDIServer in $VDIHostsobj.Server)
 
                                $obj.Server,$htmlwhite, <>                                 $VDIServer,$htmlwhite,
                                $obj.Type,$htmlwhite,                                   $VDIType,$htmlwhite,
                                $obj.PrintingState,$htmlwhite)                                   $VDIHostsPrintingState,$htmlwhite)
 
                        $Table.Columns.Item(1).Width = 275; <>                         $Table.Columns.Item(1).Width = 100;
                        $Table.Columns.Item(2).Width = 100;                           $Table.Columns.Item(2).Width = 275;
 
                        $columnWidths = @("300","100") <>                         $columnWidths = @("100","300")
 
                $RDSObjects     = New-Object System.Collections.ArrayList +-  
                $VDIHostObjects = New-Object System.Collections.ArrayList    
                    
 
                                WIAState = "Disabled" <>                                 WIAState = $False
                                TWAINState = "Disabled"                                   TWAINState = $False
 
                        $Null = $RDSObjects.Add($RDSobj) +-  
 
                                WIAState = "Disabled" <>                                 WIAState = $False
                                TWAINState = "Disabled"                                   TWAINState = $False
 
                        $Null = $RDSObjects.Add($RDSobj) +-  
 
                        ForEach($Result in $Results) <>  
                        {    
                                If($Result.EnableWIA)    
                                {    
                                        $WIAState = "Enabled"    
                                }    
                                Else    
                                {    
                                        $WIAState = "Disabled"    
                                }    
                                    
                                If($Result.EnableTWAIN)    
                                {    
                                        $TWAINState = "Enabled"    
                                }    
                                Else    
                                {    
                                        $TWAINState = "Disabled"    
                                }    
     
                                $RDSobj = [PSCustomObject] @{                           $RDSobj = [PSCustomObject] @{
                                        Server = $Result.Server                                   Server = $Results.Server
                                        Type = "RD Session Hosts"                                   Type = "RD Session Hosts"
                                        WIAState = $WIAState                                   WIAState = $Results.EnableWIA
                                        TWAINState = $TwainState                                   TWAINState = $Results.EnableTWAIN
                                }    
                                $Null = $RDSObjects.Add($RDSobj)    
 
                                WIAState = "Disabled" <>                                 WIAState = $False
                                TWAINState = "Disabled"                                   TWAINState = $False
 
                        $Null = $VDIHostObjects.Add($VDIHostsobj) +-  
 
                                WIAState = "Disabled" <>                                 WIAState = $False
                                TWAINState = "Disabled"                                   TWAINState = $False
 
                        $Null = $VDIHostObjects.Add($VDIHostsobj) +-  
 
                        ForEach($Result in $Results) <>  
                        {    
                                If($Result.EnableWIA)    
                                {    
                                        $WIAState = "Enabled"    
                                }    
                                Else    
                                {    
                                        $WIAState = "Disabled"    
                                }    
                                    
                                If($Result.EnableTWAIN)    
                                {    
                                        $TWAINState = "Enabled"    
                                }    
                                Else    
                                {    
                                        $TWAINState = "Disabled"    
                                }    
     
                                $VDIHostsobj = [PSCustomObject] @{                           $VDIHostsobj = [PSCustomObject] @{
                                        Server = $Result.Server                                   Server = $Results.Server
                                        Type = "VDI Providers"                                   Type = "VDI Providers"
                                        WIAState = $WIAState                                   WIAState = $Results.EnableWIA
                                        TWAINState = $TWAINState                                   TWAINState = $Results.EnableTWAIN
                                }    
                                $Null = $VDIHostObjects.Add($VDIHostsobj)    
 
                OutputUniversalScanningSettings $WIAobj $TWAINobj $RDSobjects $VDIHostobjects <>                 OutputUniversalScanningSettings $WIAobj $TWAINobj $RDSobj $VDIHostsobj
 
  -+         $RDSType = $RDSObj.Type
            $VDIType = $VDIHostsObj.Type
            
 
  <>                 $cnt = -1
                ForEach($obj in $RDSObj)                   ForEach($RDSServer in $RDSobj.Server)
 
  -+                         $cnt++
 
                                Server = $obj.Server <>                                 Server = $RDSServer
                                Type   = $obj.Type                                   Type   = $RDSType
                                State  = $obj.WIAState                                   State  = $RDSobj.WIAState[$cnt].ToString()
 
  <>                 $cnt = -1
                ForEach($obj in $VDIHostsobj)                   ForEach($VDIServer in $VDIHostsobj.Server)
 
  -+                         $cnt++
 
                                Server = $obj.Server <>                                 Server = $VDIServer
                                Type   = $obj.Type                                   Type   = $VDIType
                                State  = $obj.WIAState                                   State  = $VDIHostsobj.WIAState[$cnt].ToString()
 
  <>                 $cnt = -1
                ForEach($obj in $RDSobj)                   ForEach($RDSServer in $RDSobj.Server)
 
  -+                         $cnt++
 
                                $obj.Server,  <>                                 $RDSServer, 
                                $obj.Type,                                    $RDSType, 
                                $obj.WIAState                                   $RDSobj.WIAState[$cnt].ToString()
 
  <>                 $cnt = -1
                ForEach($obj in $VDIHostsobj)                   ForEach($VDIServer in $VDIHostsobj.Server)
 
  -+                         $cnt++
 
                                $obj.Server,  <>                                 $VDIServer, 
                                $obj.Type,                                    $VDIType, 
                                $obj.WIAState                                   $VDIHostsobj.WIAState[$cnt].ToString()
 
  +-  
 
  <>                 $cnt = -1
                ForEach($obj in $RDSobj)                   ForEach($RDSServer in $RDSobj.Server)
 
  -+                         $cnt++
 
                                $obj.Server,$htmlwhite, <>                                 $RDSServer,$htmlwhite,
                                $obj.Type,$htmlwhite,                                   $RDSType,$htmlwhite,
                                $obj.WIAState,$htmlwhite)                                   $RDSobj.WIAState[$cnt].ToString(),$htmlwhite)
 
        <>                 
                    $cnt = -1
                ForEach($obj in $VDIHostsobj)                   ForEach($VDIServer in $VDIHostsobj.Server)
 
  -+                         $cnt++
 
                                $obj.Server,$htmlwhite, <>                                 $VDIServer,$htmlwhite,
                                $obj.Type,$htmlwhite,                                   $VDIType,$htmlwhite,
                                $obj.WIAState,$htmlwhite)                                   $VDIHostsobj.WIAState[$cnt].ToString(),$htmlwhite)
 
  <>                 $cnt = -1
                ForEach($obj in $RDSobj)                   ForEach($RDSServer in $RDSobj.Server)
 
  -+                         $cnt++
 
                                Server = $obj.Server <>                                 Server = $RDSServer
                                Type   = $obj.Type                                   Type   = $RDSType
                                State  = $obj.TwainState                                   State  = $RDSobj.TwainState[$cnt].ToString()
 
  <>                 $cnt = -1
                ForEach($obj in $VDIHostsobj)                   ForEach($VDIServer in $VDIHostsobj.Server)
 
  -+                         $cnt++
 
                                Server = $obj.Server <>                                 Server = $VDIServer
                                Type   = $obj.Type                                   Type   = $VDIType
                                State  = $obj.TwainState                                   State  = $VDIHostsobj.TwainState[$cnt].ToString()
 
  <>                 $cnt = -1
                ForEach($obj in $RDSobj)                   ForEach($RDSServer in $RDSobj.Server)
 
  -+                         $cnt++
 
                                $obj.Server,  <>                                 $RDSServer, 
                                $obj.Type,                                    $RDSType, 
                                $obj.TwainState                                   $RDSobj.TwainState[$cnt].ToString()
 
  <>                 $cnt = -1
                ForEach($obj in $VDIHostsobj)                   ForEach($VDIServer in $VDIHostsobj.Server)
 
  -+                         $cnt++
 
                                $obj.Server,  <>                                 $VDIServer, 
                                $obj.Type,                                    $VDIType, 
                                $obj.TwainState                                   $VDIHostsobj.TwainState[$cnt].ToString()
 
  +-  
 
  <>                 $cnt = -1
                ForEach($obj in $RDSobj)                   ForEach($RDSServer in $RDSobj.Server)
 
  -+                         $cnt++
 
                                $obj.Server,$htmlwhite, <>                                 $RDSServer,$htmlwhite,
                                $obj.Type,$htmlwhite,                                   $RDSType,$htmlwhite,
                                $obj.TwainState,$htmlwhite)                                   $RDSobj.TwainState[$cnt].ToString(),$htmlwhite)
 
  <>                 $cnt = -1
                ForEach($obj in $VDIHostsobj)                   ForEach($VDIServer in $VDIHostsobj.Server)
 
  -+                         $cnt++
 
                                $obj.Server,$htmlwhite, <>                                 $VDIServer,$htmlwhite,
                                $obj.Type,$htmlwhite,                                   $VDIType,$htmlwhite,
                                $obj.TwainState,$htmlwhite)                                   $VDIHostsobj.TwainState[$cnt].ToString(),$htmlwhite)
 
        Write-Verbose "$(Get-Date -Format G): `tProcessing Multi-Factor authentication" <>         Write-Verbose "$(Get-Date -Format G): `tProcessing Second level authentication"
 
        $MFA = Get-RASMFA -SiteId $Site.Id -EA 0 4>$Null <>         $results = Get-RAS2FASetting -SiteId $Site.Id -EA 0 4>$Null
 
                Unable to retrieve Multi-Factor authentication information <>                 Unable to retrieve Second level authentication information
 
                        WriteWordLine 0 0 "Unable to retrieve Multi-Factor authentication information" <>                         WriteWordLine 0 0 "Unable to retrieve Second level authentication information"
 
                        Line 0 "Unable to retrieve Multi-Factor authentication information" <>                         Line 0 "Unable to retrieve Second level authentication information"
 
                        WriteHTMLLine 0 0 "Unable to retrieve Multi-Factor authentication information" <>                         WriteHTMLLine 0 0 "Unable to retrieve Second level authentication information"
 
        ElseIf($? -and $null -eq $MFA) <>         ElseIf($? -and $null -eq $results)
 
                No Multi-Factor authentication information was found <>                 No Second level authentication information was found
 
                        WriteWordLine 0 0 "No Multi-Factor authentication information was found" <>                         WriteWordLine 0 0 "No Second level authentication information was found"
 
                        Line 0 "No Multi-Factor authentication information was found" <>                         Line 0 "No Second level authentication information was found"
 
                        WriteHTMLLine 0 0 "No Multi-Factor authentication information was found" <>                         WriteHTMLLine 0 0 "No Second level authentication information was found"
 
                OutputMFASetting $MFA <>                 Output2FASetting $results
 
         <>  
 
Function OutputMFASetting <> Function Output2FASetting
 
        Param([object] $RASMFASettings) <>         Param([object] $RAS2FASettings)
 
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Multi-Factor authentication" <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput Second level authentication"
 
                WriteWordLine 2 0 "Multi-Factor authentication" <>                 WriteWordLine 2 0 "Multi-factor authentication"
 
                Line 1 "Multi-Factor authentication" <>                 Line 1 "Multi-factor authentication"
 
                WriteHTMLLine 2 0 "Multi-Factor authentication" <>                 WriteHTMLLine 2 0 "Multi-factor authentication"
 
        ForEach($RASMFASetting in $RASMFASettings) <>  
        {    
                Switch ($RASMFASetting.Type)           Switch ($RAS2FASettings.Provider)
                {           {
                        "None"                  {$RASMFASettingProvider = "None"; Break}                   "None"                  {$RAS2FASettingsProvider = "None"; Break}
                        "Deepnet"               {$RASMFASettingProvider = "Deepnet"; Break}                   "Deepnet"               {$RAS2FASettingsProvider = "Deepnet"; Break}
                        "SafeNet"               {$RASMFASettingProvider = "SafeNet"; Break}                   "SafeNet"               {$RAS2FASettingsProvider = "SafeNet"; Break}
                        "Radius"                {$RASMFASettingProvider = "RADIUS"; Break}                   "Radius"                {$RAS2FASettingsProvider = "RADIUS"; Break}
                        "AzureRadius"   {$RASMFASettingProvider = "Azure MFA server (RADIUS)"; Break}                   "AzureRadius"   {$RAS2FASettingsProvider = "Azure MFA server (RADIUS)"; Break}
                        "DuoRadius"     {$RASMFASettingProvider = "Duo (RADIUS)"; Break}                   "DuoRadius"     {$RAS2FASettingsProvider = "Duo (RADIUS)"; Break}
                        "FortiRadius"   {$RASMFASettingProvider = "FortiAuthenticator (RADIUS)"; Break}                   "FortiRadius"   {$RAS2FASettingsProvider = "FortiAuthenticator (RADIUS)"; Break}
                        "TekRadius"     {$RASMFASettingProvider = "TekRADIUS"; Break}                   "TekRadius"     {$RAS2FASettingsProvider = "TekRADIUS"; Break}
                        "GAuthTOTP"             {$RASMFASettingProvider = "Google Authenticator"; Break}                   "GAuthTOTP"             {$RAS2FASettingsProvider = "Google Authenticator"; Break}
                        Default                 {$RASMFASettingProvider = "Unable to determine MFA Provider: $($RASMFASetting.Type)"; Break}                   Default                 {$RAS2FASettingsProvider = "Unable to determine 2FA Provider: $($RAS2FASettings.Provider)"; Break}
                }           }
 
                If($MSWord -or $PDF) <>         If($MSWord -or $PDF)
                {           {
                        WriteWordLine 3 0 "Provider settings"                   WriteWordLine 3 0 "Provider settings"
                        $ScriptInformation = New-Object System.Collections.ArrayList                   $ScriptInformation = New-Object System.Collections.ArrayList
                        $ScriptInformation.Add(@{Data = "Provider"; Value = $RASMFASettingProvider; }) > $Null                   $ScriptInformation.Add(@{Data = "Provider"; Value = $RAS2FASettingsProvider; }) > $Null
                                          
                        If($RASMFASettingProvider -ne "None")                   If($RAS2FASettingsProvider -ne "None")
                        {                   {
                                $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null                           $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null
                                                          
                                If($RASMFASetting.Type -eq "AzureRadius")                           If($RAS2FASettings.Provider -eq "AzureRadius")
                                {                           {
                                        $ScriptInformation.Add(@{Data = "     General"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "          Enable MFA provider in site"; Value = $RASMFASetting.Enabled.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "          Name"; Value = $RASMFASetting.Name; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "          Description"; Value = $RASMFASetting.Description; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "          Type"; Value = $RASMFASetting.DisplayName; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Display Name"; Value = $RASMFASetting.DisplayName; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.AzureRadiusSettings.TypeName; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RASMFASetting.Server; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RAS2FASettings.AzureRadiusSettings.Server; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RASMFASetting.BackupServer; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RAS2FASettings.AzureRadiusSettings.BackupServer; }) > $Null
                                        If($RASMFASetting.HAMode -eq "Parallel")                                   If($RAS2FASettings.AzureRadiusSettings.HAMode -eq "Parallel")
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null                                           $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null                                           $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                        }    
                                        $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "          Timeout (seconds)"; Value = $RASMFASetting.Timeout; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null    
                                        $cnt=0    
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)    
                                        {    
                                                $cnt++    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.RadiusAttrName)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.VendorID)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                        }    
                                        $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null    
                                        $cnt=0    
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)    
                                        {    
                                                $cnt++    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Enable Action: $($Item.Enabled.ToString())"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Description: $($Item.Description)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Action message: $($Item.ActionMessage)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                        }    
 
                                ElseIf($RASMFASetting.Type -eq "DuoRadius") <>  
                                {    
                                        $ScriptInformation.Add(@{Data = "          Type"; Value = $RASMFASetting.DisplayName; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "          Primary Server"; Value = $RASMFASetting.Server; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "          Secondary Server"; Value = $RASMFASetting.BackupServer; }) > $Null    
                                        If($RASMFASetting.HAMode -eq "Parallel")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null    
                                        }    
                                        $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.AzureRadiusSettings.Port; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RASMFASetting.Timeout; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.AzureRadiusSettings.Timeout; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.AzureRadiusSettings.Retries; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.AzureRadiusSettings.PasswordEncoding; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.AzureRadiusSettings.UsernameOnly.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.AzureRadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)                                   ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AttributeInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                           $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                        }                                   }
                                        $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)                                   ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AutomationInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                           $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                        }                                   }
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "FortiRadius")                           ElseIf($RAS2FASettings.Provider -eq "DuoRadius")
                                {                           {
                                        $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RASMFASetting.DisplayName; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.DuoRadiusSettings.TypeName; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RASMFASetting.Server; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Primary Server"; Value = $RAS2FASettings.DuoRadiusSettings.Server; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RASMFASetting.BackupServer; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Secondary Server"; Value = $RAS2FASettings.DuoRadiusSettings.BackupServer; }) > $Null
                                        If($RASMFASetting.HAMode -eq "Parallel")                                   If($RAS2FASettings.DuoRadiusSettings.HAMode -eq "Parallel")
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null                                           $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null                                           $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                        }                                   }
                                        $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.DuoRadiusSettings.Port; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RASMFASetting.Timeout; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.DuoRadiusSettings.Timeout; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.DuoRadiusSettings.Retries; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.DuoRadiusSettings.PasswordEncoding; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.DuoRadiusSettings.UsernameOnly.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.DuoRadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)                                   ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AttributeInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                           $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                        }                                   }
                                        $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)                                   ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AutomationInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                           $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                        }                                   }
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "TekRadius")                           ElseIf($RAS2FASettings.Provider -eq "FortiRadius")
                                {                           {
                                        $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RASMFASetting.DisplayName; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.FortiRadiusSettings.TypeName; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RASMFASetting.Server; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RAS2FASettings.FortiRadiusSettings.Server; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RASMFASetting.BackupServer; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RAS2FASettings.FortiRadiusSettings.BackupServer; }) > $Null
                                        If($RASMFASetting.HAMode -eq "Parallel")                                   If($RAS2FASettings.FortiRadiusSettings.HAMode -eq "Parallel")
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null                                           $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null                                           $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                        }                                   }
                                        $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.FortiRadiusSettings.Port; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RASMFASetting.Timeout; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.FortiRadiusSettings.Timeout; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.FortiRadiusSettings.Retries; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.FortiRadiusSettings.PasswordEncoding; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.FortiRadiusSettings.UsernameOnly.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.FortiRadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)                                   ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AttributeInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                           $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                        }                                   }
                                        $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)                                   ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AutomationInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                           $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                        }                                   }
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "Radius")                           ElseIf($RAS2FASettings.Provider -eq "TekRadius")
                                {                           {
                                        $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RASMFASetting.DisplayName; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.TekRadiusSettings.TypeName; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RASMFASetting.Server; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RAS2FASettings.TekRadiusSettings.Server; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RASMFASetting.BackupServer; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RAS2FASettings.TekRadiusSettings.BackupServer; }) > $Null
                                        If($RASMFASetting.HAMode -eq "Parallel")                                   If($RAS2FASettings.TekRadiusSettings.HAMode -eq "Parallel")
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null                                           $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null                                           $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                        }                                   }
                                        $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.TekRadiusSettings.Port; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RASMFASetting.Timeout; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.TekRadiusSettings.Timeout; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.TekRadiusSettings.Retries; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.TekRadiusSettings.PasswordEncoding; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.TekRadiusSettings.UsernameOnly.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.TekRadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null    
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)                                   ForEach($Item in $RAS2FASettings.TekRadiusSettings.AttributeInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                           $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                        }                                   }
                                        $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)                                   ForEach($Item in $RAS2FASettings.TekRadiusSettings.AutomationInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                           $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                        }                                   }
                                }                           }
                            ElseIf($RAS2FASettings.Provider -eq "Radius")
                            {
                                    $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.RadiusSettings.TypeName; }) > $Null
                                    $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RAS2FASettings.RadiusSettings.Server; }) > $Null
                                    $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RAS2FASettings.RadiusSettings.BackupServer; }) > $Null
                                    If($RAS2FASettings.RadiusSettings.HAMode -eq "Parallel")
                                    {
                                            $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                    }
                                    Else
                                    {
                                            $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                    }
                                    $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.RadiusSettings.Port; }) > $Null
                                    $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.RadiusSettings.Timeout; }) > $Null
                                    $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.RadiusSettings.Retries; }) > $Null
                                    $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.RadiusSettings.PasswordEncoding; }) > $Null
                                    $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.RadiusSettings.UsernameOnly.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.RadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                    $cnt=0
                                    ForEach($Item in $RAS2FASettings.RadiusSettings.AttributeInfoList)
                                    {
                                            $cnt++
                                            $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                    }
                                    $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                    $cnt=0
                                    ForEach($Item in $RAS2FASettings.RadiusSettings.AutomationInfoList)
                                    {
                                            $cnt++
                                            $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                    }
                            }
                                ElseIf($RASMFASetting.Type -eq "Deepnet")                           ElseIf($RAS2FASettings.Provider -eq "Deepnet")
                                {                           {
                                        Switch($RASMFASetting.AuthMode)                                   Switch($RAS2FASettings.DeepnetSettings.AuthMode)
                                        {                                   {
                                                "MandatoryForAllUsers"                                          {$DeepNetAuthMode = "Mandatory for all users"; Break}                                           "MandatoryForAllUsers"                                          {$DeepNetAuthMode = "Mandatory for all users"; Break}
                                                "CreateTokenForDomainAuthenticatedUsers"        {$DeepNetAuthMode = "Create token for Domain Authenticated users"; Break}                                           "CreateTokenForDomainAuthenticatedUsers"        {$DeepNetAuthMode = "Create token for Domain Authenticated users"; Break}
                                                "UsersWithSafeNetAcc"                                           {$DeepNetAuthMode = "Use only for users with a safe account"; Break}                                           "UsersWithSafeNetAcc"                                           {$DeepNetAuthMode = "Use only for users with a safe account"; Break}
                                                Default                                                                         {$DeepNetAuthMode = "Deepnet mode not found: $($RASMFASetting.AuthMode)"; Break}                                           Default                                                                         {$DeepNetAuthMode = "Deepnet mode not found: $($RAS2FASettings.DeepnetSettings.AuthMode)"; Break}
                                        }                                   }
                                                                          
                                        $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Type"; Value = $RASMFASetting.DeepnetType; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Type"; Value = $RAS2FASettings.DeepnetSettings.DeepnetType; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Server"; Value = $RASMFASetting.Server; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Server"; Value = $RAS2FASettings.DeepnetSettings.Server; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.DeepnetSettings.Port.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Enable SSL"; Value = $RASMFASetting.SSL.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "          Enable SSL"; Value = $RAS2FASettings.DeepnetSettings.SSL.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Agent"; Value = $RASMFASetting.DeepnetAgent; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Agent"; Value = $RAS2FASettings.DeepnetSettings.DeepnetAgent; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Application"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Application"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Application"; Value = $RASMFASetting.App; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Application"; Value = $RAS2FASettings.DeepnetSettings.App; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Domain"; Value = $RASMFASetting.DefaultDomain; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Domain"; Value = $RAS2FASettings.DeepnetSettings.DefaultDomain; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Mode"; Value = $DeepNetAuthMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Mode"; Value = $DeepNetAuthMode; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Token Type"; Value = $RASMFASetting.TokenType.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "          Token Type"; Value = $RAS2FASettings.DeepnetSettings.TokenType.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Allow Channels"; Value = "Email: $($RASMFASetting.ActivateEmail.ToString())"; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Allow Channels"; Value = "Email: $($RAS2FASettings.DeepnetSettings.ActivateEmail.ToString())"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "                        "; Value = "SMS: $($RASMFASetting.ActivateSMS.ToString())"; }) > $Null                                   $ScriptInformation.Add(@{Data = "                        "; Value = "SMS: $($RAS2FASettings.DeepnetSettings.ActivateSMS.ToString())"; }) > $Null
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "SafeNet")                           ElseIf($RAS2FASettings.Provider -eq "SafeNet")
                                {                           {
                                        Switch($RASMFASetting.AuthMode)                                   Switch($RAS2FASettings.SafeNetSettings.AuthMode)
                                        {                                   {
                                                "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}                                           "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}
                                                "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}                                           "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}
                                                "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}                                           "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}
                                                Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RASMFASetting.AuthMode)"; Break}                                           Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RAS2FASettings.SafeNetSettings.AuthMode)"; Break}
                                        }                                   }
 
                                        $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          OTP Service URL"; Value = $RASMFASetting.OTPServiceURL; }) > $Null                                   $ScriptInformation.Add(@{Data = "          OTP Service URL"; Value = $RAS2FASettings.SafeNetSettings.OTPServiceURL; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          Mode"; Value = $SafeNetAuthMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Mode"; Value = $SafeNetAuthMode; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          TMS Web API URL"; Value = $RASMFASetting.TMSWebApiURL; }) > $Null                                   $ScriptInformation.Add(@{Data = "          TMS Web API URL"; Value = $RAS2FASettings.SafeNetSettings.TMSWebApiURL; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          User Repository"; Value = $RASMFASetting.UserRepository; }) > $Null                                   $ScriptInformation.Add(@{Data = "          User Repository"; Value = $RAS2FASettings.SafeNetSettings.UserRepository; }) > $Null
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "GAuthTOTP")                           ElseIf($RAS2FASettings.Provider -eq "GAuthTOTP")
                                {                           {
                                        Switch($RASMFASetting.UserEnrollment)                                   Switch($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)
                                        {                                   {
                                                "Allow"                 {$GAuthAllow = "Allow"; Break}                                           "Allow"                 {$GAuthAllow = "Allow"; Break}
                                                "AllowUntil"    {$GAuthAllow = "Allow until"; Break}                                           "AllowUntil"    {$GAuthAllow = "Allow until"; Break}
                                                "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}                                           "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}
                                                Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RASMFASetting.UserEnrollment)"; Break}                                           Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)"; Break}
                                        }                                   }
                                                                          
                                        Switch($RASMFASetting.Tolerance)                                   Switch($RAS2FASettings.GAuthTOTPSettings.Tolerance)
                                        {                                   {
                                                0               {$TOTPTolerance = "None"; Break}                                           0               {$TOTPTolerance = "None"; Break}
                                                30              {$TOTPTolerance = "+/- 30 seconds"; Break}                                           30              {$TOTPTolerance = "+/- 30 seconds"; Break}
                                                60              {$TOTPTolerance = "+/- 60 seconds"; Break}                                           60              {$TOTPTolerance = "+/- 60 seconds"; Break}
                                                90              {$TOTPTolerance = "+/- 90 seconds"; Break}                                           90              {$TOTPTolerance = "+/- 90 seconds"; Break}
                                                120             {$TOTPTolerance = "+/- 120 seconds"; Break}                                           120             {$TOTPTolerance = "+/- 120 seconds"; Break}
                                                Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}                                           Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}
                                        }                                   }
                                                                          
                                        $ScriptInformation.Add(@{Data = "     Type Name"; Value = $RASMFASetting.Type; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Type Name"; Value = $RAS2FASettings.GAuthTOTPSettings.Type; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     User Enrollment"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     User Enrollment"; Value = ""; }) > $Null
                                        If($GAuthAllow -eq "Allow until")                                   If($GAuthAllow -eq "Allow until")
                                        {                                   {
                                                $GAuthFullDate = $RASMFASetting.UntilDateTime                                           $GAuthFullDate = $RAS2FASettings.GAuthTOTPSettings.UntilDateTime
                                                $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()                                           $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()
                                                $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()                                           $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()
                                                $ScriptInformation.Add(@{Data = "          $GAuthAllow"; Value = "Date: $GAuthDate"; }) > $Null                                           $ScriptInformation.Add(@{Data = "          $GAuthAllow"; Value = "Date: $GAuthDate"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "Time: $GAuthTime"; }) > $Null                                           $ScriptInformation.Add(@{Data = ""; Value = "Time: $GAuthTime"; }) > $Null
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "          $GAuthAllow"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "          $GAuthAllow"; Value = ""; }) > $Null
                                        }                                   }
                                        $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "          TOTP tolerence"; Value = $TOTPTolerance; }) > $Null                                   $ScriptInformation.Add(@{Data = "          TOTP tolerence"; Value = $TOTPTolerance; }) > $Null
                                }                           }
 
                                <#If($RASMFASetting.RestrictionMode -eq "Exclusion") <>                         If($RAS2FASettings.RestrictionMode -eq "Exclusion")
                                {                           {
                                        $ScriptInformation.Add(@{Data = "Enable MFA for all users except"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable MFA for all users except"; Value = ""; }) > $Null
                                }                           }
                                Else                           Else
                                {                           {
                                        $ScriptInformation.Add(@{Data = "Disable MFA for all users except"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Disable MFA for all users except"; Value = ""; }) > $Null
                                }#>                           }
                                                          
                                $Table = AddWordTable -Hashtable $ScriptInformation `                           $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                           -Columns Data,Value `
                                -List `                           -List `
                                -Format $wdTableGrid `                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 250; <>                         $Table.Columns.Item(1).Width = 250;
                                $Table.Columns.Item(2).Width = 175;                           $Table.Columns.Item(2).Width = 175;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                         FindWordDocumentEnd
                                $Table = $Null                           $Table = $Null
                                WriteWordLine 0 0 ""                           WriteWordLine 0 0 ""
 
                                <#WriteWordLine 3 0 "Restrictions" <>                         WriteWordLine 3 0 "Restriction"
                                $ScriptInformation = New-Object System.Collections.ArrayList                           $ScriptInformation = New-Object System.Collections.ArrayList
                                $ScriptInformation.Add(@{Data = "User or group list"; Value = $RASMFASetting.ExcludeUserGroup.ToString(); }) > $Null                           $ScriptInformation.Add(@{Data = "User or group list"; Value = $RAS2FASettings.ExcludeUserGroup.ToString(); }) > $Null
                                If($RASMFASetting.ExcludeUserGroup)                           If($RAS2FASettings.ExcludeUserGroup)
                                {                           {
                                        If($RASMFASetting.ExcludeUserGroupList.Count -gt 0)                                   If($RAS2FASettings.ExcludeUserGroupList.Count -gt 0)
                                        {                                   {
                                                ForEach($Item in $RASMFASetting.ExcludeUserGroupList)                                           ForEach($Item in $RAS2FASettings.ExcludeUserGroupList)
                                                {                                           {
                                                        $ScriptInformation.Add(@{Data = ""; Value = "User: $($Item.Account)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "User: $($Item.Account)"; }) > $Null
                                                        $ScriptInformation.Add(@{Data = ""; Value = "Type: $($Item.Type)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "Type: $($Item.Type)"; }) > $Null
                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                }                                           }
                                        }                                   }
                                }                           }
 
                                $ScriptInformation.Add(@{Data = "Client IP list"; Value = $RASMFASetting.ExcludeClientIPs.ToString(); }) > $Null <>                         $ScriptInformation.Add(@{Data = "Client IP list"; Value = $RAS2FASettings.ExcludeClientIPs.ToString(); }) > $Null
                                If($RASMFASetting.ExcludeClientIPs)                           If($RAS2FASettings.ExcludeClientIPs)
                                {                           {
                                        If($RASMFASetting.ExcludeClientIPList.Count -gt 0)                                   If($RAS2FASettings.ExcludeClientIPList.Count -gt 0)
                                        {                                   {
                                                $cnt     = -1                                           $cnt     = -1
                                                $MaxFrom = (($RASMFASetting.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)                                           $MaxFrom = (($RAS2FASettings.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)
                                                $MaxTo   = (($RASMFASetting.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)                                           $MaxTo   = (($RAS2FASettings.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)
 
                                                ForEach($Item in $RASMFASetting.ExcludeClientIPList) <>                                         ForEach($Item in $RAS2FASettings.ExcludeClientIPList)
                                                {                                           {
                                                        $cnt++                                                   $cnt++
                                                        $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)                                                   $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                                                                          
                                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                                        {                                                   {
                                                                $ScriptInformation.Add(@{Data = "     IPv4 Addresses"; Value = $tmp; }) > $Null                                                           $ScriptInformation.Add(@{Data = "     IPv4 Addresses"; Value = $tmp; }) > $Null
                                                        }                                                   }
                                                        Else                                                   Else
                                                        {                                                   {
                                                                $ScriptInformation.Add(@{Data = ""; Value = $tmp; }) > $Null                                                           $ScriptInformation.Add(@{Data = ""; Value = $tmp; }) > $Null
                                                        }                                                   }
                                                }                                           }
                                        }                                   }
                                                                          
                                        If($RASMFASetting.ExcludeClientIPv6List.Count -gt 0)                                   If($RAS2FASettings.ExcludeClientIPv6List.Count -gt 0)
                                        {                                   {
                                                $cnt     = -1                                           $cnt     = -1
                                                $MaxFrom = (($RASMFASetting.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)                                           $MaxFrom = (($RAS2FASettings.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)
                                                $MaxTo   = (($RASMFASetting.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)                                           $MaxTo   = (($RAS2FASettings.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)
 
                                                ForEach($Item in $RASMFASetting.ExcludeClientIPv6List) <>                                         ForEach($Item in $RAS2FASettings.ExcludeClientIPv6List)
                                                {                                           {
                                                        $cnt++                                                   $cnt++
                                                        $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)                                                   $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                                                                          
                                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                                        {                                                   {
                                                                $ScriptInformation.Add(@{Data = "     IPv6 Addresses"; Value = $tmp; }) > $Null                                                           $ScriptInformation.Add(@{Data = "     IPv6 Addresses"; Value = $tmp; }) > $Null
                                                        }                                                   }
                                                        Else                                                   Else
                                                        {                                                   {
                                                                $ScriptInformation.Add(@{Data = ""; Value = $tmp; }) > $Null                                                           $ScriptInformation.Add(@{Data = ""; Value = $tmp; }) > $Null
                                                        }                                                   }
                                                }                                           }
                                        }                                   }
                                }                           }
 
                                $ScriptInformation.Add(@{Data = "Client MAC list"; Value = $RASMFASetting.ExcludeClientMAC.ToString(); }) > $Null <>                         $ScriptInformation.Add(@{Data = "Client MAC list"; Value = $RAS2FASettings.ExcludeClientMAC.ToString(); }) > $Null
                                If($RASMFASetting.ExcludeClientMAC)                           If($RAS2FASettings.ExcludeClientMAC)
                                {                           {
                                        $cnt = -1                                   $cnt = -1
                                        ForEach($MAC in $RASMFASetting.ExcludeClientMACList)                                   ForEach($MAC in $RAS2FASettings.ExcludeClientMACList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                                                          
                                                If($cnt -eq 0)                                           If($cnt -eq 0)
                                                {                                           {
                                                        $ScriptInformation.Add(@{Data = "     MAC Address"; Value = $MAC; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     MAC Address"; Value = $MAC; }) > $Null
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                        $ScriptInformation.Add(@{Data = ""; Value = $MAC; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = $MAC; }) > $Null
                                                }                                           }
                                        }                                   }
                                }                           }
 
                                $ScriptInformation.Add(@{Data = "Connection to the following Gateway IPs"; Value = $RASMFASetting.ExcludeClientGWIPs.ToString(); }) > $Null <>                         $ScriptInformation.Add(@{Data = "Connection to the following Gateway IPs"; Value = $RAS2FASettings.ExcludeClientGWIPs.ToString(); }) > $Null
                                If($RASMFASetting.ExcludeClientGWIPs)                           If($RAS2FASettings.ExcludeClientGWIPs)
                                {                           {
                                        $cnt = -1                                   $cnt = -1
                                        ForEach($Server in $RASMFASetting.ExcludeClientGWIPList)                                   ForEach($Server in $RAS2FASettings.ExcludeClientGWIPList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                                                          
                                                If($cnt -eq 0)                                           If($cnt -eq 0)
                                                {                                           {
                                                        $ScriptInformation.Add(@{Data = "     Server Name"; Value = $Server; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Server Name"; Value = $Server; }) > $Null
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                        $ScriptInformation.Add(@{Data = ""; Value = $Server; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = $Server; }) > $Null
                                                }                                           }
                                        }                                   }
                                }                           }
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                           -Columns Data,Value `
                                -List `                           -List `
                                -Format $wdTableGrid `                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 250; <>                         $Table.Columns.Item(1).Width = 250;
                                $Table.Columns.Item(2).Width = 250;                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                         FindWordDocumentEnd
                                $Table = $Null                           $Table = $Null
                                WriteWordLine 0 0 ""#>                           WriteWordLine 0 0 ""
                        }                   }
     
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RAS2FASettings.ReplicateSettings.ToString(); }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 250;
                    $Table.Columns.Item(2).Width = 175;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
                }           }
                If($Text)           If($Text)
                {           {
                        Line 2 "Provider settings"                   Line 2 "Provider settings"
                        Line 3 "Provider: " $RASMFASettingProvider                   Line 3 "Provider: " $RAS2FASettingsProvider
                        If($RASMFASettingProvider -ne "None")                   If($RAS2FASettingsProvider -ne "None")
                        {                   {
                                Line 3 "Settings"                           Line 3 "Settings"
                                                          
                                If($RASMFASetting.Type -eq "AzureRadius")                           If($RAS2FASettings.Provider -eq "AzureRadius")
                                {                           {
                                        Line 4 "General"    
                                        Line 5 "Enable MFA provider in site`t: " $RASMFASetting.Enabled.ToString()    
                                        Line 5 "Name`t`t`t`t: " $RASMFASetting.Name    
                                        Line 5 "Description`t`t`t: " $RASMFASetting.Description    
                                        Line 5 "Type`t`t`t`t: " $RASMFASetting.DisplayName    
                                        Line 4 "Connection"                                   Line 4 "Connection"
                                        Line 5 "Display Name`t`t`t: " $RASMFASetting.DisplayName    
                                        Line 5 "Primary server`t`t`t: " $RASMFASetting.Server    
                                        Line 5 "Secondary server`t`t: " $RASMFASetting.BackupServer    
                                        If($RASMFASetting.HAMode -eq "Parallel")    
                                        {    
                                                Line 5 "HA mode`t`t`t`t: Active - active (parallel)"    
                                        }    
                                        Else    
                                        {    
                                                Line 5 "HA mode`t`t`t`t: Active - passive (failover)"    
                                        }    
                                        Line 5 "Port`t`t`t`t: " $RASMFASetting.Port    
                                        Line 5 "Timeout (seconds)`t`t: " $RASMFASetting.Timeout    
                                        Line 5 "Retries`t`t`t`t: " $RASMFASetting.Retries    
                                        Line 5 "Password Encoding`t`t: " $RASMFASetting.PasswordEncoding    
                                        Line 5 "Forward username only to "    
                                        Line 5 "Radius Server`t`t`t: " $RASMFASetting.UsernameOnly.ToString()    
                                        Line 5 "Forward the first password to "    
                                        Line 5 "Windows authentication provider`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()    
                                        Line 4 "Attributes"    
                                        $cnt=0    
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)    
                                        {    
                                                $cnt++    
                                                Line 5 "Attribute $cnt"    
                                                Line 6 "Name`t: $($Item.RadiusAttrName)"    
                                                Line 6 "Vendor`t: $($Item.VendorID)"    
                                                Line 6 "Type`t: $($Item.AttributeType)"    
                                                Line 6 "Value`t: $($Item.Value)"    
                                                Line 5 "" #blank separator line    
                                        }    
                                        Line 5 "Automation"    
                                        $cnt=0    
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)    
                                        {    
                                                $cnt++    
                                                Line 5 "Automation $cnt"    
                                                Line 6 "Enable Action`t: $($Item.Enabled.ToString())"    
                                                Line 6 "Title`t`t: $($Item.Title)"    
                                                Line 6 "Command`t`t: $($Item.Command)"    
                                                Line 6 "Description`t: $($Item.Description)"    
                                                Line 6 "Action message`t: $($Item.ActionMessage)"    
                                                Line 6 "Image`t`t: $($Item.Image)"    
                                                Line 6 "Autosend`t: $($Item.AutoSend.ToString())"    
                                                Line 6 "" #blank separator line    
                                        }    
                                        Line 0 ""    
                                }    
                                ElseIf($RASMFASetting.Type -eq "DuoRadius")    
                                {    
                                        Line 4 "Connection"    
                                        Line 5 "Type Name`t`t`t`t: " $RASMFASetting.DisplayName                                   Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.TypeName
                                        Line 5 "Primary Server`t`t`t`t: " $RASMFASetting.Server                                   Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.Server
                                        Line 5 "Secondary server`t`t`t: " $RASMFASetting.BackupServer                                   Line 5 "Secondary server`t`t`t: " $RAS2FASettings.AzureRadiusSettings.BackupServer
                                        If($RASMFASetting.HAMode -eq "Parallel")                                   If($RAS2FASettings.AzureRadiusSettings.HAMode -eq "Parallel")
                                        {                                   {
                                                Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"                                           Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"                                           Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"
                                        }    
                                        Line 5 "Port`t`t`t`t`t: " $RASMFASetting.Port    
                                        Line 5 "Timeout`t`t`t`t`t: " $RASMFASetting.Timeout    
                                        Line 5 "Retries`t`t`t`t`t: " $RASMFASetting.Retries    
                                        Line 5 "Password Encoding`t`t`t: " $RASMFASetting.PasswordEncoding    
                                        Line 5 "Forward username only to Radius Server`t: " $RASMFASetting.UsernameOnly.ToString()    
                                        Line 5 "Forward the first password to "    
                                        Line 5 "Windows authentication provider`t`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()    
                                        Line 4 "Attributes"    
                                        $cnt=0    
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)    
                                        {    
                                                $cnt++    
                                                Line 5 "Attribute $cnt"    
                                                Line 6 "Name`t: $($Item.RadiusAttrName)"    
                                                Line 6 "Vendor`t: $($Item.VendorID)"    
                                                Line 6 "Type`t: $($Item.AttributeType)"    
                                                Line 6 "Value`t: $($Item.Value)"    
                                                Line 5 "" #blank separator line    
                                        }    
                                        Line 4 "Automation"    
                                        $cnt=0    
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)    
                                        {    
                                                $cnt++    
                                                Line 5 "" "Automation $cnt"    
                                                Line 6 "Enable Action`t: $($Item.Enabled.ToString())"    
                                                Line 6 "Title`t`t: $($Item.Title)"    
                                                Line 6 "Command`t`t: $($Item.Command)"    
                                                Line 6 "Description`t: $($Item.Description)"    
                                                Line 6 "Action message`t: $($Item.ActionMessage)"    
                                                Line 6 "Image`t`t: $($Item.Image)"    
                                                Line 6 "Autosend`t: $($Item.AutoSend.ToString())"    
                                                Line 5 "" "" #blank separator line    
                                        }    
                                        Line 0 ""    
 
                                ElseIf($RASMFASetting.Type -eq "FortiRadius") <>  
                                {    
                                        Line 4 "Connection"    
                                        Line 5 "Type Name`t`t`t`t: " $RASMFASetting.DisplayName    
                                        Line 5 "Primary Server`t`t`t`t: " $RASMFASetting.Server    
                                        Line 5 "Secondary server`t`t`t: " $RASMFASetting.BackupServer    
                                        If($RASMFASetting.HAMode -eq "Parallel")    
                                        {    
                                                Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"    
                                        }    
                                        Else    
                                        {    
                                                Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"    
                                        }    
                                        Line 5 "Port`t`t`t`t`t: " $RASMFASetting.Port                                   Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.Port
                                        Line 5 "Timeout`t`t`t`t`t: " $RASMFASetting.Timeout                                   Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.Timeout
                                        Line 5 "Retries`t`t`t`t`t: " $RASMFASetting.Retries                                   Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.Retries
                                        Line 5 "Password Encoding`t`t`t: " $RASMFASetting.PasswordEncoding                                   Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.AzureRadiusSettings.PasswordEncoding
                                        Line 5 "Forward username only to Radius Server`t: " $RASMFASetting.UsernameOnly.ToString()                                   Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.AzureRadiusSettings.UsernameOnly.ToString()
                                        Line 5 "Forward the first password to "                                   Line 5 "Forward the first password to "
                                        Line 5 "Windows authentication provider`t`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()                                   Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.AzureRadiusSettings.ForwardFirstPwdToAD.ToString()
                                        Line 4 "Attributes"                                   Line 4 "Attributes"
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)                                   ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AttributeInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                Line 5 "Attribute $cnt"                                           Line 5 "Attribute $cnt"
                                                Line 6 "Name  : $($Item.Name)"                                           Line 6 "Name  : $($Item.Name)"
                                                Line 6 "Vendor: $($Item.Vendor)"                                           Line 6 "Vendor: $($Item.Vendor)"
                                                Line 6 "Type  : $($Item.AttributeType)"                                           Line 6 "Type  : $($Item.AttributeType)"
                                                Line 6 "Value : $($Item.Value)"                                           Line 6 "Value : $($Item.Value)"
                                                Line 5 "" #blank separator line                                           Line 5 "" #blank separator line
                                        }                                   }
                                        Line 4 "Automation"                                   Line 4 "Automation"
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)                                   ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AutomationInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                Line 5 "" "Automation $cnt"                                           Line 5 "" "Automation $cnt"
                                                Line 6 "Enabled : $($Item.Enabled.ToString())"                                           Line 6 "Enabled : $($Item.Enabled.ToString())"
                                                Line 6 "Title   : $($Item.Title)"                                           Line 6 "Title   : $($Item.Title)"
                                                Line 6 "Command : $($Item.Command)"                                           Line 6 "Command : $($Item.Command)"
                                                Line 6 "Image   : $($Item.Image)"                                           Line 6 "Image   : $($Item.Image)"
                                                Line 6 "Autosend: $($Item.AutoSend.ToString())"                                           Line 6 "Autosend: $($Item.AutoSend.ToString())"
                                                Line 5 "" "" #blank separator line                                           Line 5 "" "" #blank separator line
                                        }                                   }
                                        Line 0 ""                                   Line 0 ""
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "TekRadius")                           ElseIf($RAS2FASettings.Provider -eq "DuoRadius")
                                {                           {
                                        Line 4 "Connection"                                   Line 4 "Connection"
                                        Line 5 "Type Name`t`t`t`t: " $RASMFASetting.DisplayName                                   Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.TypeName
                                        Line 5 "Primary Server`t`t`t`t: " $RASMFASetting.Server                                   Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.Server
                                        Line 5 "Secondary server`t`t`t: " $RASMFASetting.BackupServer                                   Line 5 "Secondary server`t`t`t: " $RAS2FASettings.DuoRadiusSettings.BackupServer
                                        If($RASMFASetting.HAMode -eq "Parallel")                                   If($RAS2FASettings.DuoRadiusSettings.HAMode -eq "Parallel")
                                        {                                   {
                                                Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"                                           Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"                                           Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"
                                        }                                   }
                                        Line 5 "Port`t`t`t`t`t: " $RASMFASetting.Port                                   Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.Port
                                        Line 5 "Timeout`t`t`t`t`t: " $RASMFASetting.Timeout                                   Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.Timeout
                                        Line 5 "Retries`t`t`t`t`t: " $RASMFASetting.Retries                                   Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.Retries
                                        Line 5 "Password Encoding`t`t`t: " $RASMFASetting.PasswordEncoding                                   Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.DuoRadiusSettings.PasswordEncoding
                                        Line 5 "Forward username only to Radius Server`t: " $RASMFASetting.UsernameOnly.ToString()                                   Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.DuoRadiusSettings.UsernameOnly.ToString()
                                        Line 5 "Forward the first password to "                                   Line 5 "Forward the first password to "
                                        Line 5 "Windows authentication provider`t`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()                                   Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.DuoRadiusSettings.ForwardFirstPwdToAD.ToString()
                                        Line 4 "Attributes"                                   Line 4 "Attributes"
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)                                   ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AttributeInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                Line 5 "Attribute $cnt"                                           Line 5 "Attribute $cnt"
                                                Line 6 "Name  : $($Item.Name)"                                           Line 6 "Name  : $($Item.Name)"
                                                Line 6 "Vendor: $($Item.Vendor)"                                           Line 6 "Vendor: $($Item.Vendor)"
                                                Line 6 "Type  : $($Item.AttributeType)"                                           Line 6 "Type  : $($Item.AttributeType)"
                                                Line 6 "Value : $($Item.Value)"                                           Line 6 "Value : $($Item.Value)"
                                                Line 5 "" #blank separator line                                           Line 5 "" #blank separator line
                                        }                                   }
                                        Line 4 "Automation"                                   Line 4 "Automation"
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)                                   ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AutomationInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                Line 5 "" "Automation $cnt"                                           Line 5 "" "Automation $cnt"
                                                Line 6 "Enabled : $($Item.Enabled.ToString())"                                           Line 6 "Enabled : $($Item.Enabled.ToString())"
                                                Line 6 "Title   : $($Item.Title)"                                           Line 6 "Title   : $($Item.Title)"
                                                Line 6 "Command : $($Item.Command)"                                           Line 6 "Command : $($Item.Command)"
                                                Line 6 "Image   : $($Item.Image)"                                           Line 6 "Image   : $($Item.Image)"
                                                Line 6 "Autosend: $($Item.AutoSend.ToString())"                                           Line 6 "Autosend: $($Item.AutoSend.ToString())"
                                                Line 5 "" "" #blank separator line                                           Line 5 "" "" #blank separator line
                                        }                                   }
                                        Line 0 ""                                   Line 0 ""
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "Radius")                           ElseIf($RAS2FASettings.Provider -eq "FortiRadius")
                                {                           {
                                        Line 4 "Connection"                                   Line 4 "Connection"
                                        Line 5 "Type Name`t`t`t`t: " $RASMFASetting.DisplayName                                   Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.TypeName
                                        Line 5 "Primary Server`t`t`t`t: " $RASMFASetting.Server                                   Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.Server
                                        Line 5 "Secondary server`t`t`t: " $RASMFASetting.BackupServer                                   Line 5 "Secondary server`t`t`t: " $RAS2FASettings.FortiRadiusSettings.BackupServer
                                        If($RASMFASetting.HAMode -eq "Parallel")                                   If($RAS2FASettings.FortiRadiusSettings.HAMode -eq "Parallel")
                                        {                                   {
                                                Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"                                           Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"                                           Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"
                                        }                                   }
                                        Line 5 "Port`t`t`t`t`t: " $RASMFASetting.Port                                   Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.Port
                                        Line 5 "Timeout`t`t`t`t`t: " $RASMFASetting.Timeout                                   Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.Timeout
                                        Line 5 "Retries`t`t`t`t`t: " $RASMFASetting.Retries                                   Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.Retries
                                        Line 5 "Password Encoding`t`t`t: " $RASMFASetting.PasswordEncoding                                   Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.FortiRadiusSettings.PasswordEncoding
                                        Line 5 "Forward username only to Radius Server`t: " $RASMFASetting.UsernameOnly.ToString()                                   Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.FortiRadiusSettings.UsernameOnly.ToString()
                                        Line 5 "Forward the first password to "                                   Line 5 "Forward the first password to "
                                        Line 5 "Windows authentication provider`t`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()                                   Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.FortiRadiusSettings.ForwardFirstPwdToAD.ToString()
                                        Line 4 "Attributes"                                   Line 4 "Attributes"
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)                                   ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AttributeInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                Line 5 "Attribute $cnt"                                           Line 5 "Attribute $cnt"
                                                Line 6 "Name  : $($Item.Name)"                                           Line 6 "Name  : $($Item.Name)"
                                                Line 6 "Vendor: $($Item.Vendor)"                                           Line 6 "Vendor: $($Item.Vendor)"
                                                Line 6 "Type  : $($Item.AttributeType)"                                           Line 6 "Type  : $($Item.AttributeType)"
                                                Line 6 "Value : $($Item.Value)"                                           Line 6 "Value : $($Item.Value)"
                                                Line 5 "" #blank separator line                                           Line 5 "" #blank separator line
                                        }                                   }
                                        Line 4 "Automation"                                   Line 4 "Automation"
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)                                   ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AutomationInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                Line 5 "" "Automation $cnt"                                           Line 5 "" "Automation $cnt"
                                                Line 6 "Enabled : $($Item.Enabled.ToString())"                                           Line 6 "Enabled : $($Item.Enabled.ToString())"
                                                Line 6 "Title   : $($Item.Title)"                                           Line 6 "Title   : $($Item.Title)"
                                                Line 6 "Command : $($Item.Command)"                                           Line 6 "Command : $($Item.Command)"
                                                Line 6 "Image   : $($Item.Image)"                                           Line 6 "Image   : $($Item.Image)"
                                                Line 6 "Autosend: $($Item.AutoSend.ToString())"                                           Line 6 "Autosend: $($Item.AutoSend.ToString())"
                                                Line 5 "" "" #blank separator line                                           Line 5 "" "" #blank separator line
                                        }                                   }
                                        Line 0 ""                                   Line 0 ""
                                }                           }
                            ElseIf($RAS2FASettings.Provider -eq "TekRadius")
                            {
                                    Line 4 "Connection"
                                    Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.TypeName
                                    Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.Server
                                    Line 5 "Secondary server`t`t`t: " $RAS2FASettings.TekRadiusSettings.BackupServer
                                    If($RAS2FASettings.TekRadiusSettings.HAMode -eq "Parallel")
                                    {
                                            Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"
                                    }
                                    Else
                                    {
                                            Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"
                                    }
                                    Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.Port
                                    Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.Timeout
                                    Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.Retries
                                    Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.TekRadiusSettings.PasswordEncoding
                                    Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.TekRadiusSettings.UsernameOnly.ToString()
                                    Line 5 "Forward the first password to "
                                    Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.TekRadiusSettings.ForwardFirstPwdToAD.ToString()
                                    Line 4 "Attributes"
                                    $cnt=0
                                    ForEach($Item in $RAS2FASettings.TekRadiusSettings.AttributeInfoList)
                                    {
                                            $cnt++
                                            Line 5 "Attribute $cnt"
                                            Line 6 "Name  : $($Item.Name)"
                                            Line 6 "Vendor: $($Item.Vendor)"
                                            Line 6 "Type  : $($Item.AttributeType)"
                                            Line 6 "Value : $($Item.Value)"
                                            Line 5 "" #blank separator line
                                    }
                                    Line 4 "Automation"
                                    $cnt=0
                                    ForEach($Item in $RAS2FASettings.TekRadiusSettings.AutomationInfoList)
                                    {
                                            $cnt++
                                            Line 5 "" "Automation $cnt"
                                            Line 6 "Enabled : $($Item.Enabled.ToString())"
                                            Line 6 "Title   : $($Item.Title)"
                                            Line 6 "Command : $($Item.Command)"
                                            Line 6 "Image   : $($Item.Image)"
                                            Line 6 "Autosend: $($Item.AutoSend.ToString())"
                                            Line 5 "" "" #blank separator line
                                    }
                                    Line 0 ""
                            }
                            ElseIf($RAS2FASettings.Provider -eq "Radius")
                            {
                                    Line 4 "Connection"
                                    Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.RadiusSettings.TypeName
                                    Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.RadiusSettings.Server
                                    Line 5 "Secondary server`t`t`t: " $RAS2FASettings.RadiusSettings.BackupServer
                                    If($RAS2FASettings.RadiusSettings.HAMode -eq "Parallel")
                                    {
                                            Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"
                                    }
                                    Else
                                    {
                                            Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"
                                    }
                                    Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.RadiusSettings.Port
                                    Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.RadiusSettings.Timeout
                                    Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.RadiusSettings.Retries
                                    Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.RadiusSettings.PasswordEncoding
                                    Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.RadiusSettings.UsernameOnly.ToString()
                                    Line 5 "Forward the first password to "
                                    Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.RadiusSettings.ForwardFirstPwdToAD.ToString()
                                    Line 4 "Attributes"
                                    $cnt=0
                                    ForEach($Item in $RAS2FASettings.RadiusSettings.AttributeInfoList)
                                    {
                                            $cnt++
                                            Line 5 "Attribute $cnt"
                                            Line 6 "Name  : $($Item.Name)"
                                            Line 6 "Vendor: $($Item.Vendor)"
                                            Line 6 "Type  : $($Item.AttributeType)"
                                            Line 6 "Value : $($Item.Value)"
                                            Line 5 "" #blank separator line
                                    }
                                    Line 4 "Automation"
                                    $cnt=0
                                    ForEach($Item in $RAS2FASettings.RadiusSettings.AutomationInfoList)
                                    {
                                            $cnt++
                                            Line 5 "" "Automation $cnt"
                                            Line 6 "Enabled : $($Item.Enabled.ToString())"
                                            Line 6 "Title   : $($Item.Title)"
                                            Line 6 "Command : $($Item.Command)"
                                            Line 6 "Image   : $($Item.Image)"
                                            Line 6 "Autosend: $($Item.AutoSend.ToString())"
                                            Line 5 "" "" #blank separator line
                                    }
                                    Line 0 ""
                            }
                                ElseIf($RASMFASetting.Type -eq "Deepnet")                           ElseIf($RAS2FASettings.Provider -eq "Deepnet")
                                {                           {
                                        Line 4 "Connection"                                   Line 4 "Connection"
                                        Line 5 "Type`t`t: " $RASMFASetting.DeepnetType                                   Line 5 "Type`t`t: " $RAS2FASettings.DeepnetSettings.DeepnetType
                                        Line 5 "Server`t`t: " $RASMFASetting.Server                                   Line 5 "Server`t`t: " $RAS2FASettings.DeepnetSettings.Server
                                        Line 5 "Port`t`t: " $RASMFASetting.Port.ToString()                                   Line 5 "Port`t`t: " $RAS2FASettings.DeepnetSettings.Port.ToString()
                                        Line 5 "Enable SSL`t: " $RASMFASetting.SSL.ToString()                                   Line 5 "Enable SSL`t: " $RAS2FASettings.DeepnetSettings.SSL.ToString()
                                        Line 5 "Agent`t`t: " $RASMFASetting.DeepnetAgent                                   Line 5 "Agent`t`t: " $RAS2FASettings.DeepnetSettings.DeepnetAgent
                                        Line 4 "Application"                                   Line 4 "Application"
                                        Line 5 "          Application`t: " $RASMFASetting.App                                   Line 5 "          Application`t: " $RAS2FASettings.DeepnetSettings.App
                                        Line 5 "          Domain`t: " $RASMFASetting.DefaultDomain                                   Line 5 "          Domain`t: " $RAS2FASettings.DeepnetSettings.DefaultDomain
                                        Line 4 "Authentication"                                   Line 4 "Authentication"
                                        Line 5 "          Mode`t`t: " $DeepNetAuthMode                                   Line 5 "          Mode`t`t: " $DeepNetAuthMode
                                        Line 5 "          Token Type`t: " $RASMFASetting.TokenType.ToString()                                   Line 5 "          Token Type`t: " $RAS2FASettings.DeepnetSettings.TokenType.ToString()
                                        Line 5 "          Allow Channels: " "Email: $($RASMFASetting.ActivateEmail.ToString())"                                   Line 5 "          Allow Channels: " "Email: $($RAS2FASettings.DeepnetSettings.ActivateEmail.ToString())"
                                        Line 5 "                          " "SMS: $($RASMFASetting.ActivateSMS.ToString())"                                   Line 5 "                          " "SMS: $($RAS2FASettings.DeepnetSettings.ActivateSMS.ToString())"
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "SafeNet")                           ElseIf($RAS2FASettings.Provider -eq "SafeNet")
                                {                           {
                                        Switch($RASMFASetting.AuthMode)                                   Switch($RAS2FASettings.SafeNetSettings.AuthMode)
                                        {                                   {
                                                "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}                                           "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}
                                                "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}                                           "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}
                                                "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}                                           "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}
                                                Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RASMFASetting.AuthMode)"; Break}                                           Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RAS2FASettings.SafeNetSettings.AuthMode)"; Break}
                                        }                                   }
 
                                        Line 4 "Connection" <>                                 Line 4 "Connection"
                                        Line 5 "OTP Service URL : " $RASMFASetting.DeepnetType                                   Line 5 "OTP Service URL : " $RAS2FASettings.SafeNetSettings.DeepnetType
                                        Line 4 "Authentication"                                   Line 4 "Authentication"
                                        Line 5 "Mode`t`t`t: " $SafeNetAuthMode                                   Line 5 "Mode`t`t`t: " $SafeNetAuthMode
                                        Line 5 "TMS Web API URL`t`t: " $RASMFASetting.TMSWebApiURL                                   Line 5 "TMS Web API URL`t`t: " $RAS2FASettings.SafeNetSettings.TMSWebApiURL
                                        Line 5 "User Repository`t`t: " $RASMFASetting.UserRepository                                   Line 5 "User Repository`t`t: " $RAS2FASettings.SafeNetSettings.UserRepository
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "GAuthTOTP")                           ElseIf($RAS2FASettings.Provider -eq "GAuthTOTP")
                                {                           {
                                        Switch($RASMFASetting.UserEnrollment)                                   Switch($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)
                                        {                                   {
                                                "Allow"                 {$GAuthAllow = "Allow"; Break}                                           "Allow"                 {$GAuthAllow = "Allow"; Break}
                                                "AllowUntil"    {$GAuthAllow = "Allow until"; Break}                                           "AllowUntil"    {$GAuthAllow = "Allow until"; Break}
                                                "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}                                           "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}
                                                Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RASMFASetting.UserEnrollment)"; Break}                                           Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)"; Break}
                                        }                                   }
                                                                          
                                        Switch($RASMFASetting.Tolerance)                                   Switch($RAS2FASettings.GAuthTOTPSettings.Tolerance)
                                        {                                   {
                                                0               {$TOTPTolerance = "None"; Break}                                           0               {$TOTPTolerance = "None"; Break}
                                                30              {$TOTPTolerance = "+/- 30 seconds"; Break}                                           30              {$TOTPTolerance = "+/- 30 seconds"; Break}
                                                60              {$TOTPTolerance = "+/- 60 seconds"; Break}                                           60              {$TOTPTolerance = "+/- 60 seconds"; Break}
                                                90              {$TOTPTolerance = "+/- 90 seconds"; Break}                                           90              {$TOTPTolerance = "+/- 90 seconds"; Break}
                                                120             {$TOTPTolerance = "+/- 120 seconds"; Break}                                           120             {$TOTPTolerance = "+/- 120 seconds"; Break}
                                                Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}                                           Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}
                                        }                                   }
                                                                          
                                        Line 4 "Type Name: " $RASMFASetting.Type                                   Line 4 "Type Name: " $RAS2FASettings.GAuthTOTPSettings.Type
                                        Line 4 "User Enrollment"                                   Line 4 "User Enrollment"
                                        Line 5 $GAuthAllow                                   Line 5 $GAuthAllow
                                        If($GAuthAllow -eq "Allow until")                                   If($GAuthAllow -eq "Allow until")
                                        {                                   {
                                                $GAuthFullDate = $RASMFASetting.UntilDateTime                                           $GAuthFullDate = $RAS2FASettings.GAuthTOTPSettings.UntilDateTime
                                                $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()                                           $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()
                                                $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()                                           $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()
                                                Line 6 "Date: " $GAuthDate                                           Line 6 "Date: " $GAuthDate
                                                Line 6 "Time: " $GAuthTime                                           Line 6 "Time: " $GAuthTime
                                        }                                   }
                                        Line 4 "Authentication"                                   Line 4 "Authentication"
                                        Line 5 "TOTP tolerence: " $TOTPTolerance                                   Line 5 "TOTP tolerence: " $TOTPTolerance
                                }                           }
 
                                <#If($RASMFASetting.RestrictionMode -eq "Exclusion") <>                         If($RAS2FASettings.RestrictionMode -eq "Exclusion")
                                {                           {
                                        Line 3 "Enable MFA for all users except"                                   Line 3 "Enable MFA for all users except"
                                }                           }
                                Else                           Else
                                {                           {
                                        Line 3 "Disable MFA for all users except"                                   Line 3 "Disable MFA for all users except"
                                }#>                           }
                                Line 0 ""                           Line 0 ""
 
                                <#Line 2 "Restriction" <>                         Line 2 "Restriction"
                                Line 3 "User or group list`t`t`t: " $RASMFASetting.ExcludeUserGroup.ToString()                           Line 3 "User or group list`t`t`t: " $RAS2FASettings.ExcludeUserGroup.ToString()
                                If($RASMFASetting.ExcludeUserGroup)                           If($RAS2FASettings.ExcludeUserGroup)
                                {                           {
                                        If($RASMFASetting.ExcludeUserGroupList.Count -gt 0)                                   If($RAS2FASettings.ExcludeUserGroupList.Count -gt 0)
                                        {                                   {
                                                ForEach($Item in $RASMFASetting.ExcludeUserGroupList)                                           ForEach($Item in $RAS2FASettings.ExcludeUserGroupList)
                                                {                                           {
                                                        Line 8 "  " "User: $($Item.Account)"                                                   Line 8 "  " "User: $($Item.Account)"
                                                        Line 8 "  " "Type: $($Item.Type)"                                                   Line 8 "  " "Type: $($Item.Type)"
                                                        Line 8 "  "                                                   Line 8 "  "
                                                }                                           }
                                        }                                   }
                                }                           }
                                                                          
                                Line 3 "Client IP list`t`t`t`t: " $RASMFASetting.ExcludeClientIPs.ToString()                           Line 3 "Client IP list`t`t`t`t: " $RAS2FASettings.ExcludeClientIPs.ToString()
                                If($RASMFASetting.ExcludeClientIPs)                           If($RAS2FASettings.ExcludeClientIPs)
                                {                           {
                                        If($RASMFASetting.ExcludeClientIPList.Count -gt 0)                                   If($RAS2FASettings.ExcludeClientIPList.Count -gt 0)
                                        {                                   {
                                                $cnt     = -1                                           $cnt     = -1
                                                $MaxFrom = (($RASMFASetting.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)                                           $MaxFrom = (($RAS2FASettings.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)
                                                $MaxTo   = (($RASMFASetting.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)                                           $MaxTo   = (($RAS2FASettings.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)
 
                                                ForEach($Item in $RASMFASetting.ExcludeClientIPList) <>                                         ForEach($Item in $RAS2FASettings.ExcludeClientIPList)
                                                {                                           {
                                                        $cnt++                                                   $cnt++
                                                        $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)                                                   $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                                                                          
                                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                                        {                                                   {
                                                                Line 6 "IPv4 Addresses`t: " $tmp                                                           Line 6 "IPv4 Addresses`t: " $tmp
                                                        }                                                   }
                                                        Else                                                   Else
                                                        {                                                   {
                                                                Line 8 "  " $tmp                                                           Line 8 "  " $tmp
                                                        }                                                   }
                                                }                                           }
                                        }                                   }
                                                                          
                                        If($RASMFASetting.ExcludeClientIPv6List.Count -gt 0)                                   If($RAS2FASettings.ExcludeClientIPv6List.Count -gt 0)
                                        {                                   {
                                                $cnt     = -1                                           $cnt     = -1
                                                $MaxFrom = (($RASMFASetting.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)                                           $MaxFrom = (($RAS2FASettings.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)
                                                $MaxTo   = (($RASMFASetting.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)                                           $MaxTo   = (($RAS2FASettings.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)
 
                                                ForEach($Item in $RASMFASetting.ExcludeClientIPv6List) <>                                         ForEach($Item in $RAS2FASettings.ExcludeClientIPv6List)
                                                {                                           {
                                                        $cnt++                                                   $cnt++
                                                        $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)                                                   $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                                                                          
                                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                                        {                                                   {
                                                                Line 6 "IPv6 Addresses`t: " $tmp                                                           Line 6 "IPv6 Addresses`t: " $tmp
                                                        }                                                   }
                                                        Else                                                   Else
                                                        {                                                   {
                                                                Line 8 "  " $tmp                                                           Line 8 "  " $tmp
                                                        }                                                   }
                                                }                                           }
                                        }                                   }
                                }                           }
                                Line 3 "Client MAC list`t`t`t`t: " $RASMFASetting.ExcludeClientMAC.ToString()                           Line 3 "Client MAC list`t`t`t`t: " $RAS2FASettings.ExcludeClientMAC.ToString()
                                If($RASMFASetting.ExcludeClientMAC)                           If($RAS2FASettings.ExcludeClientMAC)
                                {                           {
                                        $cnt = -1                                   $cnt = -1
                                        ForEach($MAC in $RASMFASetting.ExcludeClientMACList)                                   ForEach($MAC in $RAS2FASettings.ExcludeClientMACList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                                                          
                                                If($cnt -eq 0)                                           If($cnt -eq 0)
                                                {                                           {
                                                        Line 6 "MAC Address`t: " $MAC                                                   Line 6 "MAC Address`t: " $MAC
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                        Line 8 "  " $MAC                                                   Line 8 "  " $MAC
                                                }                                           }
                                        }                                   }
                                }                           }
                                Line 3 "Connection to the following Gateway IPs`t: " $RASMFASetting.ExcludeClientGWIPs.ToString()                           Line 3 "Connection to the following Gateway IPs`t: " $RAS2FASettings.ExcludeClientGWIPs.ToString()
                                If($RASMFASetting.ExcludeClientGWIPs)                           If($RAS2FASettings.ExcludeClientGWIPs)
                                {                           {
                                        $cnt = -1                                   $cnt = -1
                                        ForEach($Server in $RASMFASetting.ExcludeClientGWIPList)                                   ForEach($Server in $RAS2FASettings.ExcludeClientGWIPList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                                                          
                                                If($cnt -eq 0)                                           If($cnt -eq 0)
                                                {                                           {
                                                        Line 6 "Server Name`t: " $Server                                                   Line 6 "Server Name`t: " $Server
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                        Line 8 "  " $Server                                                   Line 8 "  " $Server
                                                }                                           }
                                        }                                   }
                                }#>                           }
                        }                   }
                        Line 0 ""                   Line 0 ""
                    Line 2 "Settings are replicated to all Sites`t`t: " $RAS2FASettings.ReplicateSettings.ToString()
                    Line 0 ""
                }           }
                If($HTML)           If($HTML)
                {           {
                        $rowdata = @()                   $rowdata = @()
                        $columnHeaders = @("Provider",($Script:htmlsb),$RASMFASettingProvider,$htmlwhite)                   $columnHeaders = @("Provider",($Script:htmlsb),$RAS2FASettingsProvider,$htmlwhite)
                        If($RASMFASettingProvider -ne "None")                   If($RAS2FASettingsProvider -ne "None")
                        {                   {
                                If($RASMFASetting.Type -eq "AzureRadius")                           If($RAS2FASettings.Provider -eq "AzureRadius")
                                {                           {
                                        $rowdata += @(,( "     General",($Script:htmlsb),"",$htmlwhite))    
                                        $rowdata += @(,("          Enable MFA provider in site",($Script:htmlsb),$RASMFASetting.Enabled.ToString(),$htmlwhite))    
                                        $rowdata += @(,("          Name",($Script:htmlsb),$RASMFASetting.Name,$htmlwhite))    
                                        $rowdata += @(,("          Description",($Script:htmlsb), $RASMFASetting.Description,$htmlwhite))    
                                        $rowdata += @(,("          Type",($Script:htmlsb), $RASMFASetting.DisplayName,$htmlwhite))    
                                        $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,("          Display Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))                                   $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.TypeName,$htmlwhite))
                                        $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))                                   $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.Server,$htmlwhite))
                                        $rowdata += @(,("          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))                                   $rowdata += @(,("          Secondary server",($Script:htmlsb), $RAS2FASettings.AzureRadiusSettings.BackupServer,$htmlwhite))
                                        If($RASMFASetting.HAMode -eq "Parallel")                                   If($RAS2FASettings.AzureRadiusSettings.HAMode -eq "Parallel")
                                        {                                   {
                                                $rowdata += @(,("          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))                                           $rowdata += @(,("          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $rowdata += @(,("          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))                                           $rowdata += @(,("          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                        }    
                                        $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))    
                                        $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))    
                                        $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))    
                                        $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))    
                                        $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))    
                                        $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))    
                                        $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))    
                                        $cnt=0    
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)    
                                        {    
                                                $cnt++    
                                                $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))    
                                                $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.RadiusAttrName)",$htmlwhite))    
                                                $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.VendorID)",$htmlwhite))    
                                                $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))    
                                                $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))    
                                                $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                        }    
                                        $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))    
                                        $cnt=0    
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)    
                                        {    
                                                $cnt++    
                                                $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))    
                                                $rowdata += @(,( "",($Script:htmlsb), "     Enabled Action: $($Item.Enabled.ToString())",$htmlwhite))    
                                                $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))    
                                                $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))    
                                                $rowdata += @(,( "",($Script:htmlsb), "     Description: $($Item.Description)",$htmlwhite))    
                                                $rowdata += @(,( "",($Script:htmlsb), "     Action message: $($Item.ActionMessage)",$htmlwhite))    
                                                $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))    
                                                $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))    
                                                $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                        }    
 
                                ElseIf($RASMFASetting.Type -eq "DuoRadius") <>  
                                {    
                                        $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))    
                                        $rowdata += @(,("          Type Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))    
                                        $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))    
                                        $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))    
                                        If($RASMFASetting.HAMode -eq "Parallel")    
                                        {    
                                                $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))    
                                        }    
                                        $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))                                   $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.Port,$htmlwhite))
                                        $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))                                   $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.Timeout,$htmlwhite))
                                        $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))                                   $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.Retries,$htmlwhite))
                                        $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))                                   $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.PasswordEncoding.ToString(),$htmlwhite))
                                        $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))                                   $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.UsernameOnly.ToString(),$htmlwhite))
                                        $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))                                   $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                        $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)                                   ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AttributeInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                           $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                        }                                   }
                                        $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)                                   ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AutomationInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                           $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                        }                                   }
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "FortiRadius")                           ElseIf($RAS2FASettings.Provider -eq "DuoRadius")
                                {                           {
                                        $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,("          Type Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))                                   $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.TypeName,$htmlwhite))
                                        $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))                                   $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.Server,$htmlwhite))
                                        $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))                                   $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RAS2FASettings.DuoRadiusSettings.BackupServer,$htmlwhite))
                                        If($RASMFASetting.HAMode -eq "Parallel")                                   If($RAS2FASettings.DuoRadiusSettings.HAMode -eq "Parallel")
                                        {                                   {
                                                $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))                                           $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))                                           $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                        }                                   }
                                        $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))                                   $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.Port,$htmlwhite))
                                        $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))                                   $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.Timeout,$htmlwhite))
                                        $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))                                   $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.Retries,$htmlwhite))
                                        $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))                                   $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.PasswordEncoding.ToString(),$htmlwhite))
                                        $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))                                   $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.UsernameOnly.ToString(),$htmlwhite))
                                        $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))                                   $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                        $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)                                   ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AttributeInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                           $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                        }                                   }
                                        $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)                                   ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AutomationInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                           $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                        }                                   }
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "TekRadius")                           ElseIf($RAS2FASettings.Provider -eq "FortiRadius")
                                {                           {
                                        $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,("          Type Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))                                   $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.TypeName,$htmlwhite))
                                        $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))                                   $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.Server,$htmlwhite))
                                        $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))                                   $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RAS2FASettings.FortiRadiusSettings.BackupServer,$htmlwhite))
                                        If($RASMFASetting.HAMode -eq "Parallel")                                   If($RAS2FASettings.FortiRadiusSettings.HAMode -eq "Parallel")
                                        {                                   {
                                                $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))                                           $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))                                           $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                        }                                   }
                                        $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))                                   $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.Port,$htmlwhite))
                                        $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))                                   $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.Timeout,$htmlwhite))
                                        $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))                                   $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.Retries,$htmlwhite))
                                        $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))                                   $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.PasswordEncoding.ToString(),$htmlwhite))
                                        $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))                                   $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.UsernameOnly.ToString(),$htmlwhite))
                                        $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))                                   $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                        $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)                                   ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AttributeInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                           $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                        }                                   }
                                        $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)                                   ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AutomationInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                           $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                        }                                   }
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "Radius")                           ElseIf($RAS2FASettings.Provider -eq "TekRadius")
                                {                           {
                                        $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,("          Type Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))                                   $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.TypeName,$htmlwhite))
                                        $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))                                   $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.Server,$htmlwhite))
                                        $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))                                   $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RAS2FASettings.TekRadiusSettings.BackupServer,$htmlwhite))
                                        If($RASMFASetting.HAMode -eq "Parallel")                                   If($RAS2FASettings.TekRadiusSettings.HAMode -eq "Parallel")
                                        {                                   {
                                                $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))                                           $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))                                           $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                        }                                   }
                                        $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))                                   $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.Port,$htmlwhite))
                                        $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))                                   $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.Timeout,$htmlwhite))
                                        $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))                                   $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.Retries,$htmlwhite))
                                        $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))                                   $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.PasswordEncoding.ToString(),$htmlwhite))
                                        $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))                                   $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.UsernameOnly.ToString(),$htmlwhite))
                                        $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))                                   $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                        $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AttributeInfoList)                                   ForEach($Item in $RAS2FASettings.TekRadiusSettings.AttributeInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                           $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                        }                                   }
                                        $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                        $cnt=0                                   $cnt=0
                                        ForEach($Item in $RASMFASetting.AutomationInfoList)                                   ForEach($Item in $RAS2FASettings.TekRadiusSettings.AutomationInfoList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                           $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                        }                                   }
                                }                           }
                            ElseIf($RAS2FASettings.Provider -eq "Radius")
                            {
                                    $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                    $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.RadiusSettings.TypeName,$htmlwhite))
                                    $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.RadiusSettings.Server,$htmlwhite))
                                    $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RAS2FASettings.RadiusSettings.BackupServer,$htmlwhite))
                                    If($RAS2FASettings.RadiusSettings.HAMode -eq "Parallel")
                                    {
                                            $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                    }
                                    Else
                                    {
                                            $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                    }
                                    $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.RadiusSettings.Port,$htmlwhite))
                                    $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.RadiusSettings.Timeout,$htmlwhite))
                                    $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.RadiusSettings.Retries,$htmlwhite))
                                    $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.RadiusSettings.PasswordEncoding.ToString(),$htmlwhite))
                                    $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.RadiusSettings.UsernameOnly.ToString(),$htmlwhite))
                                    $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.RadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                    $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                    $cnt=0
                                    ForEach($Item in $RAS2FASettings.RadiusSettings.AttributeInfoList)
                                    {
                                            $cnt++
                                            $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                            $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))
                                            $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))
                                            $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                            $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                            $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                    }
                                    $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                    $cnt=0
                                    ForEach($Item in $RAS2FASettings.RadiusSettings.AutomationInfoList)
                                    {
                                            $cnt++
                                            $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                            $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))
                                            $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                            $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                            $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                            $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                            $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                    }
                            }
                                ElseIf($RASMFASetting.Type -eq "Deepnet")                           ElseIf($RAS2FASettings.Provider -eq "Deepnet")
                                {                           {
                                        $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,( "          Type",($Script:htmlsb), $RASMFASetting.DeepnetType,$htmlwhite))                                   $rowdata += @(,( "          Type",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.DeepnetType,$htmlwhite))
                                        $rowdata += @(,( "          Server",($Script:htmlsb), $RASMFASetting.Server,$htmlwhite))                                   $rowdata += @(,( "          Server",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.Server,$htmlwhite))
                                        $rowdata += @(,( "          Port",($Script:htmlsb), $RASMFASetting.Port.ToString(),$htmlwhite))                                   $rowdata += @(,( "          Port",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.Port.ToString(),$htmlwhite))
                                        $rowdata += @(,( "          Enable SSL",($Script:htmlsb), $RASMFASetting.SSL.ToString(),$htmlwhite))                                   $rowdata += @(,( "          Enable SSL",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.SSL.ToString(),$htmlwhite))
                                        $rowdata += @(,( "          Agent",($Script:htmlsb), $RASMFASetting.DeepnetAgent,$htmlwhite))                                   $rowdata += @(,( "          Agent",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.DeepnetAgent,$htmlwhite))
                                        $rowdata += @(,( "     Application",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Application",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,( "          Application",($Script:htmlsb), $RASMFASetting.App,$htmlwhite))                                   $rowdata += @(,( "          Application",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.App,$htmlwhite))
                                        $rowdata += @(,( "          Domain",($Script:htmlsb), $RASMFASetting.DefaultDomain,$htmlwhite))                                   $rowdata += @(,( "          Domain",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.DefaultDomain,$htmlwhite))
                                        $rowdata += @(,( "     Authentication",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Authentication",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,( "          Mode",($Script:htmlsb), $DeepNetAuthMode,$htmlwhite))                                   $rowdata += @(,( "          Mode",($Script:htmlsb), $DeepNetAuthMode,$htmlwhite))
                                        $rowdata += @(,( "          Token Type",($Script:htmlsb), $RASMFASetting.TokenType.ToString(),$htmlwhite))                                   $rowdata += @(,( "          Token Type",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.TokenType.ToString(),$htmlwhite))
                                        $rowdata += @(,( "          Allow Channels",($Script:htmlsb), "Email: $($RASMFASetting.ActivateEmail.ToString())",$htmlwhite))                                   $rowdata += @(,( "          Allow Channels",($Script:htmlsb), "Email: $($RAS2FASettings.DeepnetSettings.ActivateEmail.ToString())",$htmlwhite))
                                        $rowdata += @(,( "                        ",($Script:htmlsb), "SMS: $($RASMFASetting.ActivateSMS.ToString())",$htmlwhite))                                   $rowdata += @(,( "                        ",($Script:htmlsb), "SMS: $($RAS2FASettings.DeepnetSettings.ActivateSMS.ToString())",$htmlwhite))
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "SafeNet")                           ElseIf($RAS2FASettings.Provider -eq "SafeNet")
                                {                           {
                                        Switch($RASMFASetting.AuthMode)                                   Switch($RAS2FASettings.SafeNetSettings.AuthMode)
                                        {                                   {
                                                "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}                                           "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}
                                                "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}                                           "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}
                                                "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}                                           "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}
                                                Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RASMFASetting.AuthMode)"; Break}                                           Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RAS2FASettings.SafeNetSettings.AuthMode)"; Break}
                                        }                                   }
 
                                        $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite)) <>                                 $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,( "          OTP Service URL",($Script:htmlsb),$RASMFASetting.OTPServiceURL,$htmlwhite))                                   $rowdata += @(,( "          OTP Service URL",($Script:htmlsb),$RAS2FASettings.SafeNetSettings.OTPServiceURL,$htmlwhite))
                                        $rowdata += @(,( "     Authentication",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     Authentication",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,( "          Mode",($Script:htmlsb), $SafeNetAuthMode,$htmlwhite))                                   $rowdata += @(,( "          Mode",($Script:htmlsb), $SafeNetAuthMode,$htmlwhite))
                                        $rowdata += @(,( "          TMS Web API URL",($Script:htmlsb), $RASMFASetting.TMSWebApiURL,$htmlwhite))                                   $rowdata += @(,( "          TMS Web API URL",($Script:htmlsb), $RAS2FASettings.SafeNetSettings.TMSWebApiURL,$htmlwhite))
                                        $rowdata += @(,( "          User Repository",($Script:htmlsb), $RASMFASetting.UserRepository,$htmlwhite))                                   $rowdata += @(,( "          User Repository",($Script:htmlsb), $RAS2FASettings.SafeNetSettings.UserRepository,$htmlwhite))
                                }                           }
                                ElseIf($RASMFASetting.Type -eq "GAuthTOTP")                           ElseIf($RAS2FASettings.Provider -eq "GAuthTOTP")
                                {                           {
                                        Switch($RASMFASetting.UserEnrollment)                                   Switch($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)
                                        {                                   {
                                                "Allow"                 {$GAuthAllow = "Allow"; Break}                                           "Allow"                 {$GAuthAllow = "Allow"; Break}
                                                "AllowUntil"    {$GAuthAllow = "Allow until"; Break}                                           "AllowUntil"    {$GAuthAllow = "Allow until"; Break}
                                                "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}                                           "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}
                                                Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RASMFASetting.UserEnrollment)"; Break}                                           Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)"; Break}
                                        }                                   }
                                                                          
                                        Switch($RASMFASetting.Tolerance)                                   Switch($RAS2FASettings.GAuthTOTPSettings.Tolerance)
                                        {                                   {
                                                0               {$TOTPTolerance = "None"; Break}                                           0               {$TOTPTolerance = "None"; Break}
                                                30              {$TOTPTolerance = "+/- 30 seconds"; Break}                                           30              {$TOTPTolerance = "+/- 30 seconds"; Break}
                                                60              {$TOTPTolerance = "+/- 60 seconds"; Break}                                           60              {$TOTPTolerance = "+/- 60 seconds"; Break}
                                                90              {$TOTPTolerance = "+/- 90 seconds"; Break}                                           90              {$TOTPTolerance = "+/- 90 seconds"; Break}
                                                120             {$TOTPTolerance = "+/- 120 seconds"; Break}                                           120             {$TOTPTolerance = "+/- 120 seconds"; Break}
                                                Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}                                           Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}
                                        }                                   }
                                                                          
                                        $rowdata += @(,( "     Type Name",($Script:htmlsb),$RASMFASetting.Type,$htmlwhite))                                   $rowdata += @(,( "     Type Name",($Script:htmlsb),$RAS2FASettings.GAuthTOTPSettings.Type,$htmlwhite))
                                        $rowdata += @(,( "     User Enrollment",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,( "     User Enrollment",($Script:htmlsb),"",$htmlwhite))
                                        If($GAuthAllow -eq "Allow until")                                   If($GAuthAllow -eq "Allow until")
                                        {                                   {
                                                $GAuthFullDate = $RASMFASetting.UntilDateTime                                           $GAuthFullDate = $RAS2FASettings.GAuthTOTPSettings.UntilDateTime
                                                $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()                                           $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()
                                                $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()                                           $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()
                                                $rowdata += @(,( "          $GAuthAllow",($Script:htmlsb),"Date: $GAuthDate",$htmlwhite))                                           $rowdata += @(,( "          $GAuthAllow",($Script:htmlsb),"Date: $GAuthDate",$htmlwhite))
                                                $rowdata += @(,( "",($Script:htmlsb),"Time: $GAuthTime",$htmlwhite))                                           $rowdata += @(,( "",($Script:htmlsb),"Time: $GAuthTime",$htmlwhite))
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $rowdata += @(,( "          $GAuthAllow",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "          $GAuthAllow",($Script:htmlsb),"",$htmlwhite))
                                        }                                   }
                                        $rowdata += @(,( "     Authentication",($Script:htmlsb), "",$htmlwhite))                                   $rowdata += @(,( "     Authentication",($Script:htmlsb), "",$htmlwhite))
                                        $rowdata += @(,( "          TOTP tolerence",($Script:htmlsb), $TOTPTolerance,$htmlwhite))                                   $rowdata += @(,( "          TOTP tolerence",($Script:htmlsb), $TOTPTolerance,$htmlwhite))
                                }                           }
 
                                <#If($RASMFASetting.RestrictionMode -eq "Exclusion") <>                         If($RAS2FASettings.RestrictionMode -eq "Exclusion")
                                {                           {
                                        $rowdata += @(,("Enable MFA for all users except",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Enable MFA for all users except",($Script:htmlsb),"",$htmlwhite))
                                }                           }
                                Else                           Else
                                {                           {
                                        $rowdata += @(,("Disable MFA for all users except",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Disable MFA for all users except",($Script:htmlsb),"",$htmlwhite))
                                }#>                           }
 
                                $msg = "Provider settings" <>                         $msg = "Provider settings"
                                $columnWidths = @("300","175")                           $columnWidths = @("300","175")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                           WriteHTMLLine 0 0 ""
 
                                <# <>  
                                $rowdata = @()                           $rowdata = @()
                                $columnHeaders = @("User or group list",($Script:htmlsb),$RASMFASetting.ExcludeUserGroup.ToString(),$htmlwhite)                           $columnHeaders = @("User or group list",($Script:htmlsb),$RAS2FASettings.ExcludeUserGroup.ToString(),$htmlwhite)
                                If($RASMFASetting.ExcludeUserGroup)                           If($RAS2FASettings.ExcludeUserGroup)
                                {                           {
                                        If($RASMFASetting.ExcludeUserGroupList.Count -gt 0)                                   If($RAS2FASettings.ExcludeUserGroupList.Count -gt 0)
                                        {                                   {
                                                ForEach($Item in $RASMFASetting.ExcludeUserGroupList)                                           ForEach($Item in $RAS2FASettings.ExcludeUserGroupList)
                                                {                                           {
                                                        $rowdata += @(,("",($Script:htmlsb),"User: $($Item.Account)",$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),"User: $($Item.Account)",$htmlwhite))
                                                        $rowdata += @(,("",($Script:htmlsb),"Type: $($Item.Type)",$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),"Type: $($Item.Type)",$htmlwhite))
                                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                                }                                           }
                                        }                                   }
                                }                           }
                                                          
                                $rowdata += @(,("Client IP list",($Script:htmlsb),$RASMFASetting.ExcludeClientIPs.ToString(),$htmlwhite))                           $rowdata += @(,("Client IP list",($Script:htmlsb),$RAS2FASettings.ExcludeClientIPs.ToString(),$htmlwhite))
                                If($RASMFASetting.ExcludeClientIPs)                           If($RAS2FASettings.ExcludeClientIPs)
                                {                           {
                                        If($RASMFASetting.ExcludeClientIPList.Count -gt 0)                                   If($RAS2FASettings.ExcludeClientIPList.Count -gt 0)
                                        {                                   {
                                                $cnt     = -1                                           $cnt     = -1
                                                $MaxFrom = (($RASMFASetting.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)                                           $MaxFrom = (($RAS2FASettings.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)
                                                $MaxTo   = (($RASMFASetting.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)                                           $MaxTo   = (($RAS2FASettings.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)
 
                                                ForEach($Item in $RASMFASetting.ExcludeClientIPList) <>                                         ForEach($Item in $RAS2FASettings.ExcludeClientIPList)
                                                {                                           {
                                                        $cnt++                                                   $cnt++
                                                        $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)                                                   $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                                                                          
                                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                                        {                                                   {
                                                                $rowdata += @(,("     IPv4 Addresses",($Script:htmlsb),$tmp,$htmlwhite))                                                           $rowdata += @(,("     IPv4 Addresses",($Script:htmlsb),$tmp,$htmlwhite))
                                                        }                                                   }
                                                        Else                                                   Else
                                                        {                                                   {
                                                                $rowdata += @(,("",($Script:htmlsb),$tmp,$htmlwhite))                                                           $rowdata += @(,("",($Script:htmlsb),$tmp,$htmlwhite))
                                                        }                                                   }
                                                }                                           }
                                        }                                   }
                                                                          
                                        If($RASMFASetting.ExcludeClientIPv6List.Count -gt 0)                                   If($RAS2FASettings.ExcludeClientIPv6List.Count -gt 0)
                                        {                                   {
                                                $cnt     = -1                                           $cnt     = -1
                                                $MaxFrom = (($RASMFASetting.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)                                           $MaxFrom = (($RAS2FASettings.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)
                                                $MaxTo   = (($RASMFASetting.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)                                           $MaxTo   = (($RAS2FASettings.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)
 
                                                ForEach($Item in $RASMFASetting.ExcludeClientIPv6List) <>                                         ForEach($Item in $RAS2FASettings.ExcludeClientIPv6List)
                                                {                                           {
                                                        $cnt++                                                   $cnt++
                                                        $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)                                                   $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                                                                          
                                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                                        {                                                   {
                                                                $rowdata += @(,("     IPv6 Addresses",($Script:htmlsb),$tmp,$htmlwhite))                                                           $rowdata += @(,("     IPv6 Addresses",($Script:htmlsb),$tmp,$htmlwhite))
                                                        }                                                   }
                                                        Else                                                   Else
                                                        {                                                   {
                                                                $rowdata += @(,("",($Script:htmlsb),$tmp,$htmlwhite))                                                           $rowdata += @(,("",($Script:htmlsb),$tmp,$htmlwhite))
                                                        }                                                   }
                                                }                                           }
                                        }                                   }
                                }                           }
                                $rowdata += @(,("Client MAC list",($Script:htmlsb),$RASMFASetting.ExcludeClientMAC.ToString(),$htmlwhite))                           $rowdata += @(,("Client MAC list",($Script:htmlsb),$RAS2FASettings.ExcludeClientMAC.ToString(),$htmlwhite))
                                If($RASMFASetting.ExcludeClientMAC)                           If($RAS2FASettings.ExcludeClientMAC)
                                {                           {
                                        $cnt = -1                                   $cnt = -1
                                        ForEach($MAC in $RASMFASetting.ExcludeClientMACList)                                   ForEach($MAC in $RAS2FASettings.ExcludeClientMACList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                                                          
                                                If($cnt -eq 0)                                           If($cnt -eq 0)
                                                {                                           {
                                                        $rowdata += @(,("     MAC Address",($Script:htmlsb),$MAC,$htmlwhite))                                                   $rowdata += @(,("     MAC Address",($Script:htmlsb),$MAC,$htmlwhite))
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                        $rowdata += @(,("",($Script:htmlsb),$MAC,$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),$MAC,$htmlwhite))
                                                }                                           }
                                        }                                   }
                                }                           }
                                $rowdata += @(,("Connection to the following Gateway IPs",($Script:htmlsb),$RASMFASetting.ExcludeClientGWIPs.ToString(),$htmlwhite))                           $rowdata += @(,("Connection to the following Gateway IPs",($Script:htmlsb),$RAS2FASettings.ExcludeClientGWIPs.ToString(),$htmlwhite))
                                If($RASMFASetting.ExcludeClientGWIPs)                           If($RAS2FASettings.ExcludeClientGWIPs)
                                {                           {
                                        $cnt = -1                                   $cnt = -1
                                        ForEach($Server in $RASMFASetting.ExcludeClientGWIPList)                                   ForEach($Server in $RAS2FASettings.ExcludeClientGWIPList)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                                                          
                                                If($cnt -eq 0)                                           If($cnt -eq 0)
                                                {                                           {
                                                        $rowdata += @(,("     Server Name",($Script:htmlsb),$Server,$htmlwhite))                                                   $rowdata += @(,("     Server Name",($Script:htmlsb),$Server,$htmlwhite))
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                        $rowdata += @(,("",($Script:htmlsb),$Server,$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),$Server,$htmlwhite))
                                                }                                           }
                                        }                                   }
                                }                           }
                                                   }
                                $msg = "Restriction"                   $msg = "Restriction"
                                $columnWidths = @("300","175")                   $columnWidths = @("300","175")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                   WriteHTMLLine 0 0 ""
                                #>    
                    $rowdata = @()
                    $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$RAS2FASettings.ReplicateSettings.ToString(),$htmlwhite)
                        }    
                }                   $msg = ""
                    $columnWidths = @("300","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
 
                        ClientStatus       = $RASAllowedDevices.AllowClientAndroid <>                         ClientStatus       = $RASAllowedDevices.AllowClientWindows
                        ClientName         = "Android client"                           ClientName         = "Windows client"
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildAndroid                           ClientMinimumBuild = $RASAllowedDevices.MinBuildWindows
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientChromeApp    
                        ClientName         = "Chrome OS client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildChromeApp    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientIOS    
                        ClientName         = "iOS/iPadOS client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildIOS    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientLinux    
                        ClientName         = "Linux client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildLinux    
 
  <>                         ClientStatus       = $RASAllowedDevices.AllowClientLinux
                            ClientName         = "Linux client"
                            ClientMinimumBuild = $RASAllowedDevices.MinBuildLinux
                    }
                    
                    $AllowedDevicesWordTable += @{
                        ClientStatus       = $RASAllowedDevices.AllowClientWeb                           ClientStatus       = $RASAllowedDevices.AllowClientIOS
                        ClientName         = "User Portal (Web client)"                           ClientName         = "iOS client"
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildWeb                           ClientMinimumBuild = $RASAllowedDevices.MinBuildIOS
 
                        ClientStatus       = $RASAllowedDevices.AllowClientWindows <>                         ClientStatus       = $RASAllowedDevices.AllowClientAndroid
                        ClientName         = "Windows client"                           ClientName         = "Android client"
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildWindows                           ClientMinimumBuild = $RASAllowedDevices.MinBuildAndroid
 
  -+                         ClientStatus       = $RASAllowedDevices.AllowClientHTML5
                            ClientName         = "HTML5 client"
                            ClientMinimumBuild = $RASAllowedDevices.MinBuildHTML5
                    }
                    
                    $AllowedDevicesWordTable += @{
                            ClientStatus       = $RASAllowedDevices.AllowClientChromeApp
                            ClientName         = "Chrome client"
                            ClientMinimumBuild = $RASAllowedDevices.MinBuildChromeApp
                    }
                    
                    $AllowedDevicesWordTable += @{
                            ClientStatus       = $RASAllowedDevices.AllowClientWebPortal
                            ClientName         = "RAS Web Portal"
                            ClientMinimumBuild = $RASAllowedDevices.MinBuildWebPortal
                    }
                    
                    $AllowedDevicesWordTable += @{
 
  -+                 $AllowedDevicesWordTable += @{
                            ClientStatus       = $RASAllowedDevices.AllowClientJava
                            ClientName         = "Java client"
                            ClientMinimumBuild = $RASAllowedDevices.MinBuildJava
                    }
                    
                    $AllowedDevicesWordTable += @{
                            ClientStatus       = $RASAllowedDevices.AllowClientWinPhone
                            ClientName         = "Windows Phone client"
                            ClientMinimumBuild = $RASAllowedDevices.MinBuildWinPhone
                    }
                    
                    $AllowedDevicesWordTable += @{
                            ClientStatus       = $RASAllowedDevices.AllowClientBlackberry
                            ClientName         = "Blackberry client"
                            ClientMinimumBuild = $RASAllowedDevices.MinBuildBlackberry
                    }
                    
                    $AllowedDevicesWordTable += @{
                            ClientStatus       = $RASAllowedDevices.AllowClient2XOS
                            ClientName         = "2X OS client"
                            ClientMinimumBuild = $RASAllowedDevices.MinBuild2XOS
                    }
     
 
                Line 2 "Enabled Clients                  Minimum build" <>                 Line 2 "Enabled Clients              Minimum build"
                Line 2 "=============================================="                   Line 2 "=========================================="
                #               1234567S123456789012345678901234S12345                   #               1234567S12345678901234567890S1234
                #       False   User Portal (Web client) 99999                   #       False   WIndows Phone client 9999
                Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientWindows, "Windows client", $RASAllowedDevices.MinBuildWindows)                   Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientWindows, "Windows client", $RASAllowedDevices.MinBuildWindows)
                Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientWeb, "User Portal (Web client)", $RASAllowedDevices.MinBuildWeb)                   Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientMAC, "macOS client", $RASAllowedDevices.MinBuildMAC)
                Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientMAC, "macOS client", $RASAllowedDevices.MinBuildMAC)                   Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientLinux, "Linux client", $RASAllowedDevices.MinBuildLinux)
                Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientLinux, "Linux client", $RASAllowedDevices.MinBuildLinux)                   Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientIOS, "iOS client", $RASAllowedDevices.MinBuildIOS)
                Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientIOS, "iOS/iPadOS client", $RASAllowedDevices.MinBuildIOS)                   Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientAndroid, "Android client", $RASAllowedDevices.MinBuildAndroid)
                Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientAndroid, "Android client", $RASAllowedDevices.MinBuildAndroid)                   Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientHTML5, "HTML5 client", $RASAllowedDevices.MinBuildHTML5)
                Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientChromeApp, "Chrome OS client", $RASAllowedDevices.MinBuildChromeApp)                   Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientChromeApp, "Chrome client", $RASAllowedDevices.MinBuildChromeApp)
                    Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientWebPortal, "RAS Web Portal", $RASAllowedDevices.MinBuildWebPortal)
                Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientWyse, "Wyse client", $RASAllowedDevices.MinBuildWyse)                   Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientWyse, "Wyse client", $RASAllowedDevices.MinBuildWyse)
                    Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientJava, "Java client", $RASAllowedDevices.MinBuildJava)
                    Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientWinPhone, "Windows Phone client", $RASAllowedDevices.MinBuildWinPhone)
                    Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientBlackberry, "Blackberry client", $RASAllowedDevices.MinBuildBlackberry)
                    Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClient2XOS, "2X OS client", $RASAllowedDevices.MinBuild2XOS)
 
                $rowdata += @(,($RASAllowedDevices.AllowClientWeb,$htmlwhite,"User Portal (Web client)",$htmlwhite,$RASAllowedDevices.MinBuildWeb,$htmlwhite)) +-  
 
                $rowdata += @(,($RASAllowedDevices.AllowClientIOS,$htmlwhite,"iOS/iPadOS client",$htmlwhite,$RASAllowedDevices.MinBuildIOS,$htmlwhite)) <>                 $rowdata += @(,($RASAllowedDevices.AllowClientIOS,$htmlwhite,"iOS client",$htmlwhite,$RASAllowedDevices.MinBuildIOS,$htmlwhite))
 
  <>                 $rowdata += @(,($RASAllowedDevices.AllowClientHTML5,$htmlwhite,"HTML5 client",$htmlwhite,$RASAllowedDevices.MinBuildHTML5,$htmlwhite))
                $rowdata += @(,($RASAllowedDevices.AllowClientChromeApp,$htmlwhite,"Chrome OS client",$htmlwhite,$RASAllowedDevices.MinBuildChromeApp,$htmlwhite))                   $rowdata += @(,($RASAllowedDevices.AllowClientChromeApp,$htmlwhite,"Chrome client",$htmlwhite,$RASAllowedDevices.MinBuildChromeApp,$htmlwhite))
                    $rowdata += @(,($RASAllowedDevices.AllowClientWebPortal,$htmlwhite,"RAS Web Portal",$htmlwhite,$RASAllowedDevices.MinBuildWebPortal,$htmlwhite))
 
  -+                 $rowdata += @(,($RASAllowedDevices.AllowClientJava,$htmlwhite,"Java client",$htmlwhite,$RASAllowedDevices.MinBuildJava,$htmlwhite))
                    $rowdata += @(,($RASAllowedDevices.AllowClientWinPhone,$htmlwhite,"Windows Phone client",$htmlwhite,$RASAllowedDevices.MinBuildWinPhone,$htmlwhite))
                    $rowdata += @(,($RASAllowedDevices.AllowClientBlackberry,$htmlwhite,"Blackberry client",$htmlwhite,$RASAllowedDevices.MinBuildBlackberry,$htmlwhite))
                    $rowdata += @(,($RASAllowedDevices.AllowClient2XOS,$htmlwhite,"2X OS client",$htmlwhite,$RASAllowedDevices.MinBuild2XOS,$htmlwhite))
 
                $columnWidths = @("55","175","100") <>                 $columnWidths = @("54","125","100")
 
                <# <>  
                        $ClientOptions   = $Policy.ClientPolicy.ClientOptions                   $ClientOptions   = $Policy.ClientPolicy.ClientOptions
                        $ControlSettings = $Policy.ClientPolicy.ControlSettings                   $ControlSettings = $Policy.ClientPolicy.ControlSettings
                        $Redirection     = $Policy.ClientPolicy.Redirection                   $Redirection     = $Policy.ClientPolicy.Redirection
                        $Session         = $Policy.ClientPolicy.Session                   $Session         = $Policy.ClientPolicy.Session
                #>    
 
                $GatewayType = "" <>                 $GWType = ""
                Switch($Policy.GatewayRule)                   Switch($Policy.GWRule)
 
                        "Any"                           {$GatewayType = "if Client is connected to any gateway"; Break} <>  
                        "AnyGW"                         {$GatewayType = "if Client is connected to any gateway"; Break}                           "AnyGW"                         {$GWType = "if Client is connected to any gateway"; Break}
                        "Connected"                     {$GatewayType = "if Client is connected to one of the following gateways"; Break}    
                        "ConnectedToGWs"        {$GatewayType = "if Client is connected to one of the following gateways"; Break}                           "ConnectedToGWs"        {$GWType = "if Client is connected to one of the following gateways"; Break}
                        "NotConnected"          {$GatewayType = "if Client is not connecteed to one of the following gateways"; Break}    
                        "NotConnectedToGWs"     {$GatewayType = "if Client is not connecteed to one of the following gateways"; Break}                           "NotConnectedToGWs"     {$GWType = "if Client is not connecteed to one of the following gateways"; Break}
                        Default                         {$GatewayType = "Policy/Criteria/Gateway criteria type not found: $($Policy.GatewayRule)"; Break}                           Default                         {$GWType = "Policy/Criteria/Gateway criteria type not found: $($Policy.GWRule)"; Break}
 
                        $ScriptInformation.Add(@{Data = "Policy/Criteria/Gateway criteria/Apply policy"; Value = $GatewayType; }) > $Null <>                         $ScriptInformation.Add(@{Data = "Policy/Criteria/Gateway criteria/Apply policy"; Value = $GWType; }) > $Null
                        If($Policy.GatewayRule -ne "AnyGW")                           If($Policy.GWRule -ne "AnyGW")
 
                                ForEach($Gateway in $Policy.GatewayList) <>                                 ForEach($GW in $Policy.GWList)
 
                                        $ScriptInformation.Add(@{Data = ""; Value = $Gateway; }) > $Null <>                                         $ScriptInformation.Add(@{Data = ""; Value = $GW; }) > $Null
 
  -+                         $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/HTML5"; Value = $Policy.AllowedOSes.HTML5.ToString(); }) > $Null
 
                        $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/WebClient"; Value = $Policy.AllowedOSes.WebClient.ToString(); }) > $Null +-  
 
                        Line 3 "Policy/Criteria/Gateway criteria/Apply policy: " $GatewayType <>                         Line 3 "Policy/Criteria/Gateway criteria/Apply policy: " $GWType
                        If($Policy.GatewayRule -ne "AnyGW")                           If($Policy.GWRule -ne "AnyGW")
 
                                ForEach($Gateway in $Policy.GatewayList) <>                                 ForEach($GW in $Policy.GWList)
 
                                        Line 7 "  " $Gateway <>                                         Line 7 "  " $GW
 
                        Line 3 "Policy/Criteria/Parallels client criteria/WebClient: " $Policy.AllowedOSes.WebClient.ToString() <>                         Line 3 "Policy/Criteria/Parallels client criteria/HTML5: " $Policy.AllowedOSes.HTML5.ToString()
 
                        $columnHeaders = @("Policy/Criteria/Gateway criteria/Apply policy",($Script:htmlsb),$GatewayType,$htmlwhite) <>                         $columnHeaders = @("Policy/Criteria/Gateway criteria/Apply policy",($Script:htmlsb),$GWType,$htmlwhite)
                        If($Policy.GatewayRule -ne "AnyGW")                           If($Policy.GWRule -ne "AnyGW")
 
                                ForEach($Gateway in $Policy.GatewayList) <>                                 ForEach($GW in $Policy.GWList)
 
                                        $rowdata += @(,("",($Script:htmlsb),$Gateway,$htmlwhite)) <>                                         $rowdata += @(,("",($Script:htmlsb),$GW,$htmlwhite))
 
                        $rowdata += @(,("Policy/Criteria/Parallels client criteria/WebClient",($Script:htmlsb),$Policy.AllowedOSes.WebClient.ToString(),$htmlwhite)) <>                         $rowdata += @(,("Policy/Criteria/Parallels client criteria/HTML5",($Script:htmlsb),$Policy.AllowedOSes.HTML5.ToString(),$htmlwhite))
 
                                $GatewayMode = "" <>                                 $GWMode = ""
 
                                        "DirectMode"            {$GatewayMode = "Direct Mode"; Break} <>                                         "DirectMode"            {$GWMode = "Direct Mode"; Break}
                                        "DirectSSLMode"         {$GatewayMode = "Direct SSL Mode"; Break}                                           "DirectSSLMode"         {$GWMode = "Direct SSL Mode"; Break}
                                        "GatewayMode"           {$GatewayMode = "Gateway Mode"; Break}                                           "GatewayMode"           {$GWMode = "Gateway Mode"; Break}
                                        "GatewaySSLMode"        {$GatewayMode = "Gateway SSL Mode"; Break}                                           "GatewaySSLMode"        {$GWMode = "Gateway SSL Mode"; Break}
                                        Default                         {$GatewayMode = "Secondary connections/Secondary connections/Mode not found: $($Item.Mode)"; Break}                                           Default                         {$GWMode = "Secondary connections/Secondary connections/Mode not found: $($Item.Mode)"; Break}
 
                                                Value = "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())"; <>                                                 Value = "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())";
 
                                                "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())",$htmlwhite)) <>                                                 "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())",$htmlwhite))
 
                                                OutputPolicySetting $txt "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())" <>                                                 OutputPolicySetting $txt "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())"
 
                                                Value = "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())"; <>                                                 Value = "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())";
 
                                                "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())",$htmlwhite)) <>                                                 "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())",$htmlwhite))
 
                                                OutputPolicySetting "`t`t`t`t`t`t`t      " "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())" <>                                                 OutputPolicySetting "`t`t`t`t`t`t`t      " "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())"
 
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Disk drives and folders" <>                 Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Disk drives"
 
                        $txt = "Session/Local devices and resources/Disk drives and folders/Disk drives and folders/Allow disk drives redirection" <>                         $txt = "Session/Local devices and resources/Disk drives/Disk drives/Allow disk drives redirection"
 
                        $txt = "Session/Local devices and resources/Disk drives and folders/Disk drives and folders/Use all disk drives available" <>                         $txt = "Session/Local devices and resources/Disk drives/Disk drives/Use all disk drives available"
 
                        $txt = "Session/Local devices and resources/Disk drives and folders/Disk drives and folders/Use also disk drives that I plug in later" <>                         $txt = "Session/Local devices and resources/Disk drives/Disk drives/Use also disk drives that I plug in later"
 
                <# <>                 #can't find
                        $policy.ClientPolicy.Session.VideoCaptureDevices    
                        Enabled                   : True    
                        EnableCameras             : True    
                        DynamicCameras            : True    
                        VideoCaptureUseAllDevices : True    
                        CamerasIDs                : {*}    
                            
                        Type            Name                            Description    
                        List<String>    CamerasIDs                              Redirect to all available devices    
                        Boolean         DynamicCameras                      If box is checked allow the use of other devices that are plugged in later    
                        Boolean         EnableCameras                       If box is checked allow devices redirection    
                        Boolean         Enabled                             Whether Devices policy is enabled or not    
                        Boolean         VideoCaptureUseAllDevices               Use all devices that are available    
                #>    
                If($Policy.ClientPolicy.Session.VideoCaptureDevices.Enabled)    
                {    
                        $txt = "Session/Local devices and resources/Video capture devices/Allow devices redirection"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.VideoCaptureDevices.EnableCameras.ToString();    
                                }    
                        }    
                        If($HTML)    
                        {    
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.VideoCaptureDevices.EnableCameras.ToString(),$htmlwhite))    
                        }    
                        If($Text)    
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.VideoCaptureDevices.EnableCameras.ToString()    
                        }    
     
                        $txt = "Session/Local devices and resources/Video capture devices/Use all devices available"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.VideoCaptureDevices.VideoCaptureUseAllDevices.ToString();    
                                }    
                        }    
                        If($HTML)    
                        {    
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.VideoCaptureDevices.VideoCaptureUseAllDevices.ToString(),$htmlwhite))    
                        }    
                        If($Text)    
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.VideoCaptureDevices.VideoCaptureUseAllDevices.ToString()    
                        }    
     
                        $txt = "Session/Local devices and resources/Video capture devices/Use also devices I plug in later"    
                        If($MSWord -or $PDF)    
                        {    
                                $SettingsWordTable += @{    
                                Text = $txt;    
                                Value = $Policy.ClientPolicy.Session.VideoCaptureDevices.DynamicCameras.ToString();    
                                }    
                        }    
                        If($HTML)    
                        {    
                                $rowdata += @(,(    
                                $txt,$htmlbold,    
                                $Policy.ClientPolicy.Session.VideoCaptureDevices.DynamicCameras.ToString(),$htmlwhite))    
                        }    
                        If($Text)    
                        {    
                                OutputPolicySetting $txt $Policy.ClientPolicy.Session.VideoCaptureDevices.DynamicCameras.ToString()    
                        }    
                }    
 
                                        Value = $Policy.ClientPolicy.Session.Performance.ToString(); <>                                         Value = $Policy.ClientPolicy.Session.Performance..ToString();
 
                                        $Policy.ClientPolicy.Session.Performance.ToString(),$htmlwhite)) <>                                         $Policy.ClientPolicy.Session.Performance..ToString(),$htmlwhite))
 
                                        OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance.ToString() <>                                         OutputPolicySetting $txt $Policy.ClientPolicy.Session.Performance..ToString()
 
                        If($Policy.ClientPolicy.ClientOptions.Logging.LogLevel -ne "Standard") <>                         If($Policy.ClientPolicy.ClientOptions.Logging.LogLevel -ne "Verbose")   #Verbose from PoSH equals Standard in the console - weird
 
                                        0               {$LogDuration = ""; Break} +-  
 
                        <#$txt = "Client options/Advanced/Printing/Redirect custom paper sizes when server preferences are selected" <>                         $txt = "Client options/Advanced/Printing/Redirect custom paper sizes when server preferences are selected"
 
                        }#> <>                         }
 
                                $columnWidths = @("600","300") <>                                 $columnWidths = @("400","300")
 
        $RASFeatures = Get-RASHelpdeskEmailSettings -EA 0 4>$Null <>         $RASFeatures = Get-RASSystemSettings -EA 0 4>$Null
 
        } <>  
     
        Write-Verbose "$(Get-Date -Format G): `tProcessing Settings"    
            
        $GotRASSettings = $False    
        $RASSettings = Get-RASSystemSettings -EA 0 4>$Null    
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve settings information    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve settings information"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve settings information"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve settings information"    
                }    
        }    
        ElseIf($? -and $null -eq $RASsettings)    
        {    
                Write-Host "    
                No settings information was found    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No settings information was found"    
                }    
                If($Text)    
                {    
                        Line 0 "No settings information was found"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No settings information was found"    
                }    
        }    
        Else    
        {    
                $GotRASSettings = $True    
                OutputRASSettings $RASSettings                   OutputRASSettings $RASFeatures
 
        $RASProxySettings = Get-RASProxySettings -EA 0 4>$Null +-  
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Proxy settings information    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Proxy settings information"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Proxy settings information"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve Proxy settings information"    
                }    
        }    
        ElseIf($? -and $null -eq $RASProxySettings)    
        {    
                Write-Host "    
                No Proxy settings information was found    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Proxy settings information was found"    
                }    
                If($Text)    
                {    
                        Line 0 "No Proxy settings information was found"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Proxy settings information was found"    
                }    
        }    
        Else    
        {    
                OutputRASProxySettings $RASProxySettings    
        }    
     
        If($GotRASSettings)    
        {    
                OutputRASMiscSettings $RASSettings    
        }    
            
 
        Param([object] $RASSettings) <>         Param([object] $RASFeatures)
 
                $ScriptInformation.Add(@{Data = "Participate in the Customer Experience Program"; Value = $RASSettings.CEPEnabled.ToString(); }) > $Null <>                 $ScriptInformation.Add(@{Data = "Participate in the Customer Experience Program"; Value = $RASFeatures.CEPEnabled.ToString(); }) > $Null
 
                Line 3 "Participate in the Customer Experience Program`t`t: " $RASSettings.CEPEnabled.ToString() <>                 Line 3 "Participate in the Customer Experience Program`t`t: " $RASFeatures.CEPEnabled.ToString()
 
                $columnHeaders = @("Participate in the Customer Experience Program",($Script:htmlsb),$RASSettings.CEPEnabled.ToString(),$htmlwhite) <>                 $columnHeaders = @("Participate in the Customer Experience Program",($Script:htmlsb),$RASFeatures.CEPEnabled.ToString(),$htmlwhite)
 
} +-  
 
Function OutputRASProxySettings +-  
{    
        Param([object] $RASProxySettings)    
            
        Write-Verbose "$(Get-Date -Format G): `t`tOutput HTTP Proxy Settings"    
            
 
                If($RASProxySettings.HttpProxyMode -eq "NoProxy") <>                 If($RASFeatures.HttpProxyMode -eq "NoProxy")
 
                        $ScriptInformation.Add(@{Data = "Address"; Value = $RASProxySettings.HttpProxyAddress; }) > $Null <>                         $ScriptInformation.Add(@{Data = "Address"; Value = $RASFeatures.HttpProxyAddress; }) > $Null
                        $ScriptInformation.Add(@{Data = "Port"; Value = $RASProxySettings.HttpProxyPort; }) > $Null                           $ScriptInformation.Add(@{Data = "Port"; Value = $RASFeatures.HttpProxyPort; }) > $Null
                        $ScriptInformation.Add(@{Data = "User name"; Value = $RASProxySettings.HttpProxyUser; }) > $Null                           $ScriptInformation.Add(@{Data = "User name"; Value = $RASFeatures.HttpProxyUser; }) > $Null
                        $ScriptInformation.Add(@{Data = "Password"; Value = $RASProxySettings.HttpProxyPwd; }) > $Null                           $ScriptInformation.Add(@{Data = "Password"; Value = $RASFeatures.HttpProxyPwd; }) > $Null
 
                If($RASProxySettings.HttpProxyMode -eq "NoProxy") <>                 If($RASFeatures.HttpProxyMode -eq "NoProxy")
 
                        Line 3 "Address`t`t: " $RASProxySettings.HttpProxyAddress <>                         Line 3 "Address`t`t: " $RASFeatures.HttpProxyAddress
                        Line 3 "Port`t`t: " $RASProxySettings.HttpProxyPort                           Line 3 "Port`t`t: " $RASFeatures.HttpProxyPort
                        Line 3 "User name`t: " $RASProxySettings.HttpProxyUser                           Line 3 "User name`t: " $RASFeatures.HttpProxyUser
                        Line 3 "Password`t: " $RASProxySettings.HttpProxyPwd                           Line 3 "Password`t: " $RASFeatures.HttpProxyPwd
 
                If($RASProxySettings.HttpProxyMode -eq "NoProxy") <>                 If($RASFeatures.HttpProxyMode -eq "NoProxy")
 
                        $rowdata += @(,("Address",($Script:htmlsb),$RASProxySettings.HttpProxyAddress,$htmlwhite)) <>                         $rowdata += @(,("Address",($Script:htmlsb),$RASFeatures.HttpProxyAddress,$htmlwhite))
                        $rowdata += @(,("Port",($Script:htmlsb),$RASProxySettings.HttpProxyPort.ToString(),$htmlwhite))                           $rowdata += @(,("Port",($Script:htmlsb),$RASFeatures.HttpProxyPort.ToString(),$htmlwhite))
                        $rowdata += @(,("User name",($Script:htmlsb),$RASProxySettings.HttpProxyUser,$htmlwhite))                           $rowdata += @(,("User name",($Script:htmlsb),$RASFeatures.HttpProxyUser,$htmlwhite))
                        $rowdata += @(,("Password",($Script:htmlsb),$RASProxySettings.HttpProxyPwd,$htmlwhite))                           $rowdata += @(,("Password",($Script:htmlsb),$RASFeatures.HttpProxyPwd,$htmlwhite))
 
} +-  
 
Function OutputRASMiscSettings +-  
{    
        Param([object] $RASSettings)    
            
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Miscellaneous Settings"    
            
 
        Switch ($RASSettings.ResetIdleSessionAfterMins) <>         Switch ($RASFeatures.ResetIdleSessionAfterMins)
 
                0               {$RASSettingsResetIdleSessionAfterMins = "Never"; Break} <>                 0               {$RASFeaturesResetIdleSessionAfterMins = "Never"; Break}
                15              {$RASSettingsResetIdleSessionAfterMins = "15 minutes"; Break}                   15              {$RASFeaturesResetIdleSessionAfterMins = "15 minutes"; Break}
                30              {$RASSettingsResetIdleSessionAfterMins = "30 minutes"; Break}                   30              {$RASFeaturesResetIdleSessionAfterMins = "30 minutes"; Break}
                60              {$RASSettingsResetIdleSessionAfterMins = "1 hour"; Break}                   60              {$RASFeaturesResetIdleSessionAfterMins = "1 hour"; Break}
                180             {$RASSettingsResetIdleSessionAfterMins = "3 hours"; Break}                   180             {$RASFeaturesResetIdleSessionAfterMins = "3 hours"; Break}
                360             {$RASSettingsResetIdleSessionAfterMins = "6 hours"; Break}                   360             {$RASFeaturesResetIdleSessionAfterMins = "6 hours"; Break}
                720             {$RASSettingsResetIdleSessionAfterMins = "12 hours"; Break}                   720             {$RASFeaturesResetIdleSessionAfterMins = "12 hours"; Break}
                1440    {$RASSettingsResetIdleSessionAfterMins = "1 day"; Break}                   1440    {$RASFeaturesResetIdleSessionAfterMins = "1 day"; Break}
                Default {$RASSettingsResetIdleSessionAfterMins = "Unable to determine Console idle time: $($RASSettings.ResetIdleSessionAfterMins)"; Break}                   Default {$RASFeaturesResetIdleSessionAfterMins = "Unable to determine Console idle time: $($RASFeatures.ResetIdleSessionAfterMins)"; Break}
 
                $ScriptInformation.Add(@{Data = "Reset idle RAS Console session after"; Value = $RASSettingsResetIdleSessionAfterMins; }) > $Null <>                 $ScriptInformation.Add(@{Data = "Reset idle RAS Console session after"; Value = $RASFeaturesResetIdleSessionAfterMins; }) > $Null
 
                Line 3 "Reset idle RAS Console session after`t`t`t: " $RASSettingsResetIdleSessionAfterMins <>                 Line 3 "Reset idle RAS Console session after`t`t`t: " $RASFeaturesResetIdleSessionAfterMins
 
                $columnHeaders = @("Reset idle RAS Console session after",($Script:htmlsb),$RASSettingsResetIdleSessionAfterMins,$htmlwhite) <>                 $columnHeaders = @("Reset idle RAS Console session after",($Script:htmlsb),$RASFeaturesResetIdleSessionAfterMins,$htmlwhite)
 
                "YesIfAvailable"                {$RASMailboxSettingsUseTLS = "Use TLS/SSL if available"; Break} <>                 "YesIfAvailable"        {$RASMailboxSettingsUseTLS = "Use TLS/SSL if available"; Break}
                "Yes"                                   {$RASMailboxSettingsUseTLS = "Use TLS/SSL"; Break}                   "Yes"                           {$RASMailboxSettingsUseTLS = "Use TLS/SSL"; Break}
                "No"                                    {$RASMailboxSettingsUseTLS = "Do not use"; Break}                   "No"                            {$RASMailboxSettingsUseTLS = "Do not use"; Break}
                "3"                                             {$RASMailboxSettingsUseTLS = "Use TLS 1.2 if available"; Break}    
                "YesTLS12IfAvailable"   {$RASMailboxSettingsUseTLS = "Use TLS 1.2 if available"; Break} #fixed in 19.2, added in 3.01    
                Default                                 {$RASMailboxSettingsUseTLS = "Unable to determine TLS/SSL setting: $($RASMailboxSettings.UseTLS)"; Break}                   Default                         {$RASMailboxSettingsUseTLS = "Unable to determine TLS/SSL setting: $($RASMailboxSettings.UseTLS)"; Break}
 
                        "RDSHConnectSessionEvent"               {$RASNotificationText = "RDSH active sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold) %"; Break} <>                         "RDSHConnectSessionEvent"               {$RASNotificationText = "RDSH sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold) %"; Break}
 
                        "34660353"                                              {$RASNotificationText = "AVD active sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold) %"; Break} <>  
                        "34660354"                                              {$RASNotificationText = "AVD disconnected sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}    
                        "TunneledSess"                                  {$RASNotificationText = "Number of Secure Gateway tunnelled sessions $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}                           "TunneledSess"                                  {$RASNotificationText = "Number of gateway tunnelled sessions $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}
                        "GW"                                                    {$RASNotificationText = "Failed Secure Gateway tunnelled sessions"; Break}                           "GW"                                                    {$RASNotificationText = "Failed gateway tunnelled sessions"; Break}
                        "1097729"                                               {$RASNotificationText = "Failed Secure Gateway tunnelled sessions"; Break}                           "1097729"                                               {$RASNotificationText = "Failed gateway tunnelled sessions"; Break}
 
                        "45056"                                                 {$RASNotificationText = "Tenants events"; Break} <>                         "45056"                                                 {$RASNotificationText = "Tenants"; Break}
 
  -+  
                            #"CPU"                                                  {$RASNotificationText = ""; Break}
                            #"Disk"                                                 {$RASNotificationText = ""; Break}
                            #"Memory"                                               {$RASNotificationText = ""; Break}
                            #"RDSH"                                                 {$RASNotificationText = ""; Break}
 
                $GracePeriod           = ($RASNotificationHandler.GracePeriod.ToString()) <>                 $GracePeriod           = ($RASNotificationHandler.GracePeriod / 60)
                $NotificationsInterval = ($RASNotificationHandler.Interval.ToString())                   $NotificationsInterval = ($RASNotificationHandler.Interval / 60)
 
                        $columnWidths = @("250","225") <>                         $columnWidths = @("200","225")
 
                        $columnWidths = @("250","225") <>                         $columnWidths = @("200","225")
 
} +-  
     
Function OutputRASClientSettings    
{    
        Param([object] $RASClientSettings)    
     
        <#    
        ExcludeDirectRDP         :    
        ExcludeDirectRDPForVDI   :    
        SendHDIcons              : True    
        ReplicateSendHDIcons     : True    
        EnableOverlayIcons       : True    
        ShowPasswordExpiry       : False    
        TokenValidationExpireMin : 60    
        #>    
     
        If($MSWord -or $PDF)    
        {    
                WriteWordLine 3 0 "Client settings"    
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "Published application icons"; Value = ""; }) > $Null    
                If($RASClientSettings.SendHDIcons)    
                {    
                        $ScriptInformation.Add(@{Data = "     Resolution"; Value = "High resolution icons (uses more network bandwidth)"; }) > $Null    
                }    
                Else    
                {    
                        $ScriptInformation.Add(@{Data = "     Resolution"; Value = "Standard resolution icons"; }) > $Null    
                }    
                $ScriptInformation.Add(@{Data = "     Overlay:"; Value = $RASClientSettings.EnableOverlayIcons.ToString(); }) > $Null    
                $ScriptInformation.Add(@{Data = "Password notifications"; Value = ""; }) > $Null    
                $ScriptInformation.Add(@{Data = "     Show password expiration reminder"; Value = $RASClientSettings.ShowPasswordExpiry.ToString(); }) > $Null    
                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASClientSettings.ReplicateSendHDIcons.ToString(); }) > $Null    
     
                $Table = AddWordTable -Hashtable $ScriptInformation `    
                -Columns Data,Value `    
                -List `    
                -Format $wdTableGrid `    
                -AutoFit $wdAutoFitFixed;    
     
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                $Table.Columns.Item(1).Width = 200;    
                $Table.Columns.Item(2).Width = 250;    
     
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                FindWordDocumentEnd    
                $Table = $Null    
     
                WriteWordLine 0 0 ""    
        }    
        If($Text)    
        {    
                Line 2 "Client settings"    
                Line 3 "Published application icons"    
                If($RASClientSettings.SendHDIcons)    
                {    
                        Line 4 "Resolution`t: " "High resolution (uses more network bandwidth)"    
                }    
                Else    
                {    
                        Line 4 "Resolution`t: " "Standard resolution"    
                }    
                Line 4 "Overlay`t`t: " $RASClientSettings.EnableOverlayIcons.ToString()    
                LIne 3 "Password notifications"    
                Line 4 "Show password expiration reminder: " $RASClientSettings.ShowPasswordExpiry.ToString()    
                Line 3 "Settings are replicated to all Sites`t : " $RASClientSettings.ReplicateSendHDIcons.ToString()    
                Line 0 ""    
        }    
        If($HTML)    
        {    
                WriteHTMLLine 3 0 "Client settings"    
                $rowdata = @()    
                $columnHeaders = @("Published application icons",($Script:htmlsb),"S",$htmlwhite)    
                If($RASClientSettings.SendHDIcons)    
                {    
                        $rowdata += @(,("     Resolution:",($Script:htmlsb),"High resolution (uses more network bandwidth)",$htmlwhite))    
                }    
                Else    
                {    
                        $rowdata += @(,("     Resolution:",($Script:htmlsb),"Standard resolution",$htmlwhite))    
                }    
                $rowdata += @(,("     Overlay:",($Script:htmlsb),$RASClientSettings.EnableOverlayIcons.ToString(),$htmlwhite))    
                $rowdata += @(,("Password notifications",($Script:htmlsb),"",$htmlwhite))    
                $rowdata += @(,("     Show password expiration reminder",($Script:htmlsb),$RASClientSettings.ShowPasswordExpiry.ToString(),$htmlwhite))    
                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASClientSettings.ReplicateSendHDIcons.ToString(),$htmlwhite))    
     
                $msg = ""    
                $columnWidths = @("250","225")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
     
                WriteHTMLLine 0 0 ""    
        }    
     
 
  -+ SetFilenames "Parallels_RAS"
     
 
  +-  
SetFilenames "Parallels_RAS_$Script:RASFarmName"    
     
OutputFarm    
 
ProcessPolicies <> ProcessPolicies #new in 18.1